jongos is a tool to run and load file JSON automaticly: python jongos.py < file_name.json >.
Load JSON file
> db.load("file_name.json")
Refresh current loaded JSON file
> db.refresh()
Save current in-memory db into current loaded JSON file
> db.save()
Save query results as JSON file
> db.capture("save_to_file_name.json")
extra: execute after any db.find() / db.group() / db.count() command
Insert new record
> db.insert(json_item)
Delete record
> db.remove(query)
Find a row
> db.find(query)
extra: add "$return": [field1, field2] in query will return field1 and field2 only
Count a row that match query
> db.count(query)
Group a row with a key:
> db.group(query)
add "$key": "title" in query will using field title as your grouping key
Query
JSON structure examples:
[ {"id":1, "name": "One", "title": "Mr", "email": "one@mailinator.com", "score": {"math": 80, "science": 80} }, {"id":2, "name": "Two", "title": "Mrs", "email": "two@mailinator.com", "score": {"math": 60, "science": 70}}, {"id":3, "name": "Three", "title": "Ms", "email": "three@mailinator.com", "score": {"math": 75, "science": 90}}, {"id":4, "name": "Four", "title": "Mrs", "email": "five@mailinator.com", "score": {"math": 60, "science": 30}}, {"id":5, "name": "Five", "title": "Mrs", "email": "fivefour@mailinator.com", "score": {"math": 70, "science": 60}} ]
Match Exact, Except, Like and LikeAnd
Filter all item with Mrs title : query = {"$title": "Mrs"}
Filter all item with title except Ms : query = {"$title": {"$ne":"Ms"}}
Filter all item like 'five' in email : query = {"email": {"$like":"five"}}
Filter all item like 'five' or 'four' in email : query = {"email": {"$likes":["five","four]}}
Filter all item like 'five' and 'four' in email : query = {"email": {"$likesAnd":["five","four]}}
Greater and Lower than
Filter all math score greater than 60 : query = {"score.math": {"$gt":60}}
Filter all math score lower than 60 : query = {"score.math": {"$lt":60}}
Filter all math score greater than equal 60 : query = {"score.math": {"$gte":60}}
Filter all math score lower than equal 60 : query = {"score.math": {"$lte":60}}
Include and No Include
Filter all math score in 60 and 70: query = {"score.math": {"$in":[60,70]}}
Filter all math score not in 60 and 70 : query = {"score.math": {"$nin":[60,70]}}
Requirements:
- Python
Comments not found