Query vs DocumentQuery


  • The Node.js client provides a unified API for querying documents via the session.query() method.
    All available methods for the session's query method are listed here.

  • The query method is essentially a shorthand for invoking the documentQuery method.
    Examples of those equivalent calls are listed below.


// This collection query:
session.query(Order);

// is equivalent to this documentQuery:    
session.advanced.documentQuery(Order);
// This collection query:
session.query({ collection: "orders" });

// is equivalent to this documentQuery
session.advanced.documentQuery({
    collection: "orders",
    indexName: null,
    isMapReduce: false
});
// This index query:
session.query({ indexName: "Orders/ByShipToAndLines" });

// is equivalent to this documentQuery:
session.advanced.documentQuery({ indexName: "Orders/ByShipToAndLines" });
// This index query:
session.query({ indexName: "Orders/ByShipToAndLines" });

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