You are currently browsing legacy 4.1 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Querying: Query vs DocumentQuery

Unlike .NET, Node.js client offers single API for querying documents.

Below you can find examples of equivalent calls.

query() method in DocumentSession is shorthand for calling session.advanced.documentQuery().

session.query(Order);

is equivalent to:

session.advanced.documentQuery(Order);


session.query({ indexName: "Orders/ByShipToAndLines" });

is equivalent to:

session.advanced.documentQuery({ indexName: "Orders/ByShipToAndLines" });


session.query({ indexName: "Orders/ByShipToAndLines" });

is equivalent to:

session.advanced.documentQuery({ 
    indexName: "Orders/ByShipToAndLines", 
    isMapReduce: false,
    collection: null
});


session.query({ collection: "orders" });

is equivalent to:

session.advanced.documentQuery({ 
    collection: "orders",
    indexName: null,
    isMapReduce: false
});