djondb Guide

DQL

Document Query Language – DQL

Document Query Language is a new attempt to create a language that may be simpler to use, easier to port to other NoSQL document
stores and friendly with SQL users that are use to this kind of language.

The DQL is bad copy of SQL and allows to execute same instructions: SELECT, UPDATE, INSERT, REMOVE (DELETE). Although it’s very similar
to SQL, it has several changes to fit the document store model.

Some examples that are explained in detail in the DQL section of this manual:

INSERT { "name": "John", "lastName": "Smith" } INTO MyDB:MyNS

SELECT * FROM MyDB:MyNS
SELECT $'name', $'lastName' FROM MyDB:MyNS

UPDATE { "_id": "XYZ", "_revision": "ABC", "name": "John", "lastName": "Smithsonian"} INTO MyDB:MyNS

REMOVE "XYZ" FROM MyDB:MyNS
REMOVE "XYZ" WITH "ABC" FROM MyDB:MyNS

Using DQL

Every driver provides two methods that should be used with DQL: executeQuery and executeUpdate. At djon-shell you will be able to execute
them too.

Execute Update

"executeUpdate" is useful for any sentence that is going to change data in djondb, like inserts, updates or removes.

user@ubuntu> djon-shell
djondb shell version 0.30
> connect('localhost');
Connected to localhost

> executeUpdate("insert {'name': 'John' } into MyDB:MyNS"); 
> 

Execute Query

The "executeQuery" returns the BSONArray of a SELECT statement.

user@ubuntu> djon-shell 
djondb shell version 0.3.0
Welcome to djondb shell.
Use help(); to get the commands available. 
(hint: The first command should be "connect" to start playing with a server)
> connect('localhost');
Connected to localhost

> executeUpdate('insert { "name": "John", "age": 35 } into MyDB:MyNS');
> cur = executeQuery('select * from MyDB:MyNS');
> cur.next();
true
> cur.current();
[{"_id":"f9f08f45-02c0-4c01-9a54-0e0478e502d4","_revision":"83c04ce6-99c1-451e-a9c9-ef0eafabc509","_status":1,"age":35,"name":"John"}]
> 

Please refer to the user guide to get more information about using SELECT, UPDATE, REMOVE or INSERT.

Suggest Edit