Querying

Blini uses an immutable version of mquery to build MongoDB queries.

Comparing to Mongoose, Blini queries doesn't have a .then and promise interface, you have to explicitly call '.exec()'.

Execute the query

Query.exec(): Promise<List>

.exec returns a promise resolving with a list of all documents

Post.where('clicks').gt(999).exec()
    .then(function(list) {

    });

Stream documents

Query.stream(): ReadableStream

.exec returns a list of all documents by accumulating results from MongoDB.

Post.where('clicks').gt(999).exec()
    .then(function(list) {
        // No more results
    }, function(err) {
        // Error
    }, function(post) {
        // Receive a document
    });

Query one document

Query.findOne(): Query

Post.findOne({ _id: '...' }).exec()
    .then(function(post) {

    });``

results matching ""

    No results matching ""