- Compatible only with *nix operating systems.
- The software will run in CLI mode.
- The software must read the data that will be inside of the database.
- Data should be inserted into a database that will be persisted.
- The software should allow to query the database according to the following structure:
Where
databasic query <id> <json-path>
<id>
is a number and<json-path>
is of the form“a.b”
- The ID field of the database will be an odd integer number greater than or equal to 1.
- The input file inserted into the database system should be a JSON file provided in the following way:
databasic insert <path-to-file>
- The datatypes supported in the database will be:
- Integer
- Float
- String
- Null
- Boolean
- datetime
- {Binary} (Under consideration)
- The datetime datatype inside the JSON input/output file will in in UTC and under the RFC-3999 standard.
- When inserting a document, the registered ID for that document will printed to the stdout.
- When doing a query, the JSON/value for that document and the JSON path will be printed to the stdout.
About the input the software must:
- In the main method, open the JSON file provided in the path considering the following:
- Validate the number of parameters received be 1, ignoring others and/or returning an error message to the user.
- Validate the path is valid.
- Test the format of the file given in the path corresponds to JSON, else print an error message to the user.
- Check if file given in the path exists and open it, if there is some error print an error message to the user
- Generate an ID field for the inserted document/object and once data has been saved to database, print the ID to the user.
- Write/Update the saved file in a storing location (static). For example:
~/.databasic/
This is an JSON sample of the datatypes we are going to be using:
{
"Integer": 12,
"String": "hello world",
"Null": null,
"Boolean": true,
"Datetime": "2002-10-02T15:00:00Z"
}
When there is a query:
- In main method, read the given query provided in the CLI considering the following:
- Validate the number of parameters received be 3, ignoring others and/or returning an error message to the user.
- Validate the first given parameter be "query".
- Validate the second given parameter "ID" corresponds to a number (odd positive integer).
- Validate the third given parameter "JSON PATH" be in the form “a.b”, else print an error message to the user.
- Open the databasic JSON file, if there is some error print an error message to the user.
- Make a search in the JSON document using the given ID (first parameter) and JSON PATH.
- Print the query result to the user.
Example:
Having the following JSON Document:
{
"ID": 1,
"person": {
"name": "Javier",
"age": 35
},
"datetime": "2002-10-02T15:00:00Z"
}
The query:
databasic query 1 person.name
Returns:
“Javier”