Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mquery

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mquery - npm Package Compare versions

Comparing version 4.0.3 to 5.0.0

.github/ISSUE_TEMPLATE.md

8

History.md

@@ -0,1 +1,9 @@

5.0.0 / 2023-02-23
==================
* BREAKING CHANGE: drop callback support #137 [hasezoey](https://github.com/hasezoey)
* BREAKING CHANGE: remove custom promise library support #137 [hasezoey](https://github.com/hasezoey)
* BREAKING CHANGE: remove long deprecated `update`, `remove` functions #136 [hasezoey](https://github.com/hasezoey)
* BREAKING CHANGE: remove collection ducktyping: first param to `mquery()` is now always the query filter #138
* feat: support MongoDB Node driver 5 #137 [hasezoey](https://github.com/hasezoey)
4.0.3 / 2022-05-17

@@ -2,0 +10,0 @@ ==================

2

lib/collection/collection.js

@@ -10,7 +10,5 @@ 'use strict';

'findOne',
'update',
'updateMany',
'updateOne',
'replaceOne',
'remove',
'count',

@@ -17,0 +15,0 @@ 'distinct',

@@ -18,96 +18,78 @@ 'use strict';

/**
* find(match, options, function(err, docs))
* find(match, options)
*/
find(match, options, cb) {
async find(match, options) {
const cursor = this.collection.find(match, options);
try {
cursor.toArray(cb);
} catch (error) {
cb(error);
}
return cursor.toArray();
}
/**
* findOne(match, options, function(err, doc))
* findOne(match, options)
*/
findOne(match, options, cb) {
this.collection.findOne(match, options, cb);
async findOne(match, options) {
return this.collection.findOne(match, options);
}
/**
* count(match, options, function(err, count))
* count(match, options)
*/
count(match, options, cb) {
this.collection.count(match, options, cb);
async count(match, options) {
return this.collection.count(match, options);
}
/**
* distinct(prop, match, options, function(err, count))
* distinct(prop, match, options)
*/
distinct(prop, match, options, cb) {
this.collection.distinct(prop, match, options, cb);
async distinct(prop, match, options) {
return this.collection.distinct(prop, match, options);
}
/**
* update(match, update, options, function(err[, result]))
* updateMany(match, update, options)
*/
update(match, update, options, cb) {
this.collection.update(match, update, options, cb);
async updateMany(match, update, options) {
return this.collection.updateMany(match, update, options);
}
/**
* update(match, update, options, function(err[, result]))
* updateOne(match, update, options)
*/
updateMany(match, update, options, cb) {
this.collection.updateMany(match, update, options, cb);
async updateOne(match, update, options) {
return this.collection.updateOne(match, update, options);
}
/**
* update(match, update, options, function(err[, result]))
* replaceOne(match, update, options)
*/
updateOne(match, update, options, cb) {
this.collection.updateOne(match, update, options, cb);
async replaceOne(match, update, options) {
return this.collection.replaceOne(match, update, options);
}
/**
* replaceOne(match, update, options, function(err[, result]))
* deleteOne(match, options)
*/
replaceOne(match, update, options, cb) {
this.collection.replaceOne(match, update, options, cb);
async deleteOne(match, options) {
return this.collection.deleteOne(match, options);
}
/**
* deleteOne(match, options, function(err[, result])
* deleteMany(match, options)
*/
deleteOne(match, options, cb) {
this.collection.deleteOne(match, options, cb);
async deleteMany(match, options) {
return this.collection.deleteMany(match, options);
}
/**
* deleteMany(match, options, function(err[, result])
*/
deleteMany(match, options, cb) {
this.collection.deleteMany(match, options, cb);
}
/**
* remove(match, options, function(err[, result])
*/
remove(match, options, cb) {
this.collection.remove(match, options, cb);
}
/**
* findOneAndDelete(match, options, function(err[, result])
*/
findOneAndDelete(match, options, cb) {
this.collection.findOneAndDelete(match, options, cb);
async findOneAndDelete(match, options) {
return this.collection.findOneAndDelete(match, options);
}
/**
* findOneAndUpdate(match, update, options, function(err[, result])
* findOneAndUpdate(match, update, options)
*/
findOneAndUpdate(match, update, options, cb) {
this.collection.findOneAndUpdate(match, update, options, cb);
async findOneAndUpdate(match, update, options) {
return this.collection.findOneAndUpdate(match, update, options);
}

@@ -123,3 +105,3 @@

/**
* aggregation(operators..., function(err, doc))
* aggregation(operators...)
* TODO

@@ -126,0 +108,0 @@ */

@@ -29,4 +29,2 @@ 'use strict';

denied.distinct.batchSize =
denied.distinct.maxScan =
denied.distinct.snapshot =
denied.distinct.hint =

@@ -57,4 +55,2 @@ denied.distinct.tailable = true;

denied.findOneAndUpdate.batchSize =
denied.findOneAndUpdate.maxScan =
denied.findOneAndUpdate.snapshot =
denied.findOneAndUpdate.tailable = true;

@@ -84,4 +80,2 @@

denied.count.batchSize =
denied.count.maxScan =
denied.count.snapshot =
denied.count.tailable = true;

@@ -104,31 +104,2 @@ 'use strict';

/**
* process.nextTick helper.
*
* Wraps the given `callback` in a try/catch. If an error is
* caught it will be thrown on nextTick.
*
* node-mongodb-native had a habit of state corruption when
* an error was immediately thrown from within a collection
* method (find, update, etc) callback.
*
* @param {Function} [callback]
* @api private
*/
exports.tick = function tick(callback) {
if ('function' !== typeof callback) return;
return function() {
// callbacks should always be fired on the next
// turn of the event loop. A side benefit is
// errors thrown from executing the callback
// will not cause drivers state to be corrupted
// which has historically been a problem.
const args = arguments;
soon(function() {
callback.apply(this, args);
});
};
};
/**
* Merges `from` into `to` without overwriting existing properties.

@@ -319,11 +290,2 @@ *

/**
* nextTick helper
* compat with node 0.10 which behaves differently than previous versions
*/
const soon = exports.soon = 'function' == typeof setImmediate
? setImmediate
: process.nextTick;
/**
* Check if this object is an arguments object

@@ -330,0 +292,0 @@ *

{
"name": "mquery",
"version": "4.0.3",
"version": "5.0.0",
"description": "Expressive query building for MongoDB",
"main": "lib/mquery.js",
"scripts": {
"test": "mocha test/index.js test/*.test.js",
"test": "mocha --exit test/index.js test/*.test.js",
"fix-lint": "eslint . --fix",

@@ -16,3 +16,3 @@ "lint": "eslint ."

"engines": {
"node": ">=12.0.0"
"node": ">=14.0.0"
},

@@ -26,3 +26,3 @@ "dependencies": {

"mocha": "9.x",
"mongodb": "4.x"
"mongodb": "5.x"
},

@@ -29,0 +29,0 @@ "bugs": {

@@ -12,10 +12,10 @@ # mquery

- fluent query builder api
- custom base query support
- MongoDB 2.4 geoJSON support
- method + option combinations validation
- node.js driver compatibility
- environment detection
- [debug](https://github.com/visionmedia/debug) support
- separated collection implementations for maximum flexibility
- fluent query builder api
- custom base query support
- MongoDB 2.4 geoJSON support
- method + option combinations validation
- node.js driver compatibility
- environment detection
- [debug](https://github.com/visionmedia/debug) support
- separated collection implementations for maximum flexibility

@@ -25,18 +25,18 @@ ## Use

```js
require('mongodb').connect(uri, function (err, db) {
if (err) return handleError(err);
const mongo = require('mongodb');
// get a collection
var collection = db.collection('artists');
const client = new mongo.MongoClient(uri);
await client.connect();
// get a collection
const collection = client.collection('artists');
// pass it to the constructor
mquery(collection).find({..}, callback);
// pass it to the constructor
await mquery(collection).find({...});
// or pass it to the collection method
mquery().find({..}).collection(collection).exec(callback)
// or pass it to the collection method
const docs = await mquery().find({...}).collection(collection);
// or better yet, create a custom query constructor that has it always set
var Artist = mquery(collection).toConstructor();
Artist().find(..).where(..).exec(callback)
})
// or better yet, create a custom query constructor that has it always set
const Artist = mquery(collection).toConstructor();
const docs = await Artist().find(...).where(...);
```

@@ -46,64 +46,91 @@

## Fluent API
- [find](#find)
- [findOne](#findOne)
- [count](#count)
- [remove](#remove)
- [update](#update)
- [findOneAndUpdate](#findoneandupdate)
- [findOneAndDelete, findOneAndRemove](#findoneandremove)
- [distinct](#distinct)
- [exec](#exec)
- [stream](#stream)
- [all](#all)
- [and](#and)
- [box](#box)
- [circle](#circle)
- [elemMatch](#elemmatch)
- [equals](#equals)
- [exists](#exists)
- [geometry](#geometry)
- [gt](#gt)
- [gte](#gte)
- [in](#in)
- [intersects](#intersects)
- [lt](#lt)
- [lte](#lte)
- [maxDistance](#maxdistance)
- [mod](#mod)
- [ne](#ne)
- [nin](#nin)
- [nor](#nor)
- [near](#near)
- [or](#or)
- [polygon](#polygon)
- [regex](#regex)
- [select](#select)
- [selected](#selected)
- [selectedInclusively](#selectedinclusively)
- [selectedExclusively](#selectedexclusively)
- [size](#size)
- [slice](#slice)
- [within](#within)
- [where](#where)
- [$where](#where-1)
- [batchSize](#batchsize)
- [collation](#collation)
- [comment](#comment)
- [hint](#hint)
- [j](#j)
- [limit](#limit)
- [maxScan](#maxscan)
- [maxTime, maxTimeMS](#maxtime)
- [skip](#skip)
- [sort](#sort)
- [read, setReadPreference](#read)
- [readConcern, r](#readconcern)
- [slaveOk](#slaveok)
- [snapshot](#snapshot)
- [tailable](#tailable)
- [writeConcern, w](#writeconcern)
- [wtimeout, wTimeout](#wtimeout)
- [mquery](#mquery)
- [Features](#features)
- [Use](#use)
- [Fluent API](#fluent-api)
- [Helpers](#helpers)
- [find()](#find)
- [findOne()](#findone)
- [count()](#count)
- [findOneAndUpdate()](#findoneandupdate)
- [findOneAndUpdate() options](#findoneandupdate-options)
- [findOneAndRemove()](#findoneandremove)
- [findOneAndRemove() options](#findoneandremove-options)
- [distinct()](#distinct)
- [exec()](#exec)
- [stream()](#stream)
- [all()](#all)
- [and()](#and)
- [box()](#box)
- [circle()](#circle)
- [elemMatch()](#elemmatch)
- [equals()](#equals)
- [exists()](#exists)
- [geometry()](#geometry)
- [gt()](#gt)
- [gte()](#gte)
- [in()](#in)
- [intersects()](#intersects)
- [lt()](#lt)
- [lte()](#lte)
- [maxDistance()](#maxdistance)
- [mod()](#mod)
- [ne()](#ne)
- [nin()](#nin)
- [nor()](#nor)
- [near()](#near)
- [Example](#example)
- [or()](#or)
- [polygon()](#polygon)
- [regex()](#regex)
- [select()](#select)
- [String syntax](#string-syntax)
- [selected()](#selected)
- [selectedInclusively()](#selectedinclusively)
- [selectedExclusively()](#selectedexclusively)
- [size()](#size)
- [slice()](#slice)
- [within()](#within)
- [where()](#where)
- [$where()](#where-1)
- [batchSize()](#batchsize)
- [collation()](#collation)
- [comment()](#comment)
- [hint()](#hint)
- [j()](#j)
- [limit()](#limit)
- [maxTime()](#maxtime)
- [skip()](#skip)
- [sort()](#sort)
- [read()](#read)
- [Preferences:](#preferences)
- [Preference Tags:](#preference-tags)
- [readConcern()](#readconcern)
- [Read Concern Level:](#read-concern-level)
- [writeConcern()](#writeconcern)
- [Write Concern:](#write-concern)
- [slaveOk()](#slaveok)
- [tailable()](#tailable)
- [wtimeout()](#wtimeout)
- [Helpers](#helpers-1)
- [collection()](#collection)
- [then()](#then)
- [merge(object)](#mergeobject)
- [setOptions(options)](#setoptionsoptions)
- [setOptions() options](#setoptions-options)
- [setTraceFunction(func)](#settracefunctionfunc)
- [mquery.setGlobalTraceFunction(func)](#mquerysetglobaltracefunctionfunc)
- [mquery.canMerge(conditions)](#mquerycanmergeconditions)
- [mquery.use$geoWithin](#mqueryusegeowithin)
- [Custom Base Queries](#custom-base-queries)
- [Validation](#validation)
- [Debug support](#debug-support)
- [General compatibility](#general-compatibility)
- [ObjectIds](#objectids)
- [Read Preferences](#read-preferences)
- [Future goals](#future-goals)
- [Installation](#installation)
- [License](#license)

@@ -114,3 +141,2 @@ ## Helpers

- [then](#then)
- [thunk](#thunk)
- [merge](#mergeobject)

@@ -120,3 +146,3 @@ - [setOptions](#setoptionsoptions)

- [mquery.setGlobalTraceFunction](#mquerysetglobaltracefunctionfunc)
- [mquery.canMerge](#mquerycanmerge)
- [mquery.canMerge](#mquerycanmergeconditions)
- [mquery.use$geoWithin](#mqueryusegeowithin)

@@ -126,3 +152,3 @@

Declares this query a _find_ query. Optionally pass a match clause and / or callback. If a callback is passed the query is executed.
Declares this query a _find_ query. Optionally pass a match clause.

@@ -132,6 +158,5 @@ ```js

mquery().find(match)
mquery().find(callback)
mquery().find(match, function (err, docs) {
assert(Array.isArray(docs));
})
await mquery().find()
const docs = await mquery().find(match);
assert(Array.isArray(docs));
```

@@ -141,3 +166,3 @@

Declares this query a _findOne_ query. Optionally pass a match clause and / or callback. If a callback is passed the query is executed.
Declares this query a _findOne_ query. Optionally pass a match clause.

@@ -147,9 +172,8 @@ ```js

mquery().findOne(match)
mquery().findOne(callback)
mquery().findOne(match, function (err, doc) {
if (doc) {
// the document may not be found
console.log(doc);
}
})
await mquery().findOne()
const doc = await mquery().findOne(match);
if (doc) {
// the document may not be found
console.log(doc);
}
```

@@ -159,3 +183,3 @@

Declares this query a _count_ query. Optionally pass a match clause and / or callback. If a callback is passed the query is executed.
Declares this query a _count_ query. Optionally pass a match clause.

@@ -165,113 +189,14 @@ ```js

mquery().count(match)
mquery().count(callback)
mquery().count(match, function (err, number){
console.log('we found %d matching documents', number);
})
await mquery().count()
const number = await mquery().count(match);
console.log('we found %d matching documents', number);
```
### remove()
Declares this query a _remove_ query. Optionally pass a match clause and / or callback. If a callback is passed the query is executed.
```js
mquery().remove()
mquery().remove(match)
mquery().remove(callback)
mquery().remove(match, function (err){})
```
### update()
Declares this query an _update_ query. Optionally pass an update document, match clause, options or callback. If a callback is passed, the query is executed. To force execution without passing a callback, run `update(true)`.
```js
mquery().update()
mquery().update(match, updateDocument)
mquery().update(match, updateDocument, options)
// the following all execute the command
mquery().update(callback)
mquery().update({$set: updateDocument, callback)
mquery().update(match, updateDocument, callback)
mquery().update(match, updateDocument, options, function (err, result){})
mquery().update(true) // executes (unsafe write)
```
##### the update document
All paths passed that are not `$atomic` operations will become `$set` ops. For example:
```js
mquery(collection).where({ _id: id }).update({ title: 'words' }, callback)
```
becomes
```js
collection.update({ _id: id }, { $set: { title: 'words' }}, callback)
```
This behavior can be overridden using the `overwrite` option (see below).
##### options
Options are passed to the `setOptions()` method.
- overwrite
Passing an empty object `{ }` as the update document will result in a no-op unless the `overwrite` option is passed. Without the `overwrite` option, the update operation will be ignored and the callback executed without sending the command to MongoDB to prevent accidently overwritting documents in the collection.
```js
var q = mquery(collection).where({ _id: id }).setOptions({ overwrite: true });
q.update({ }, callback); // overwrite with an empty doc
```
The `overwrite` option isn't just for empty objects, it also provides a means to override the default `$set` conversion and send the update document as is.
```js
// create a base query
var base = mquery({ _id: 108 }).collection(collection).toConstructor();
base().findOne(function (err, doc) {
console.log(doc); // { _id: 108, name: 'cajon' })
base().setOptions({ overwrite: true }).update({ changed: true }, function (err) {
base.findOne(function (err, doc) {
console.log(doc); // { _id: 108, changed: true }) - the doc was overwritten
});
});
})
```
- multi
Updates only modify a single document by default. To update multiple documents, set the `multi` option to `true`.
```js
mquery()
.collection(coll)
.update({ name: /^match/ }, { $addToSet: { arr: 4 }}, { multi: true }, callback)
// another way of doing it
mquery({ name: /^match/ })
.collection(coll)
.setOptions({ multi: true })
.update({ $addToSet: { arr: 4 }}, callback)
// update multiple documents with an empty doc
var q = mquery(collection).where({ name: /^match/ });
q.setOptions({ multi: true, overwrite: true })
q.update({ });
q.update(function (err, result) {
console.log(arguments);
});
```
### findOneAndUpdate()
Declares this query a _findAndModify_ with update query. Optionally pass a match clause, update document, options, or callback. If a callback is passed, the query is executed.
Declares this query a _findAndModify_ with update query. Optionally pass a match clause, update document, options.
When executed, the first matching document (if found) is modified according to the update document and passed back to the callback.
When executed, the first matching document (if found) is modified according to the update document and passed back.
##### options
#### findOneAndUpdate() options

@@ -291,12 +216,11 @@ Options are passed to the `setOptions()` method.

// the following all execute the command
query.findOneAndUpdate(callback)
query.findOneAndUpdate(updateDocument, callback)
query.findOneAndUpdate(match, updateDocument, callback)
query.findOneAndUpdate(match, updateDocument, options, function (err, doc) {
if (doc) {
// the document may not be found
console.log(doc);
}
})
```
await query.findOneAndUpdate()
await query.findOneAndUpdate(updateDocument)
await query.findOneAndUpdate(match, updateDocument)
const doc = await await query.findOneAndUpdate(match, updateDocument, options);
if (doc) {
// the document may not be found
console.log(doc);
}
```

@@ -306,7 +230,7 @@ ### findOneAndRemove()

Declares this query a _findAndModify_ with remove query. Alias of findOneAndDelete.
Optionally pass a match clause, options, or callback. If a callback is passed, the query is executed.
Optionally pass a match clause, options.
When executed, the first matching document (if found) is modified according to the update document, removed from the collection and passed to the callback.
When executed, the first matching document (if found) is modified according to the update document, removed from the collection and passed as a result.
##### options
#### findOneAndRemove() options

@@ -324,15 +248,14 @@ Options are passed to the `setOptions()` method.

// the following all execute the command
A.where().findOneAndRemove(callback)
A.where().findOneAndRemove(match, callback)
A.where().findOneAndRemove(match, options, function (err, doc) {
if (doc) {
// the document may not be found
console.log(doc);
}
})
```
await A.where().findOneAndRemove()
await A.where().findOneAndRemove(match)
const doc = await A.where().findOneAndRemove(match, options);
if (doc) {
// the document may not be found
console.log(doc);
}
```
### distinct()
Declares this query a _distinct_ query. Optionally pass the distinct field, a match clause or callback. If a callback is passed the query is executed.
Declares this query a _distinct_ query. Optionally pass the distinct field, a match clause.

@@ -346,8 +269,7 @@ ```js

// the following all execute the command
mquery().distinct(callback)
mquery().distinct(field, callback)
mquery().distinct(match, callback)
mquery().distinct(match, field, function (err, result) {
console.log(result);
})
await mquery().distinct()
await mquery().distinct(field)
await mquery().distinct(match)
const result = await mquery().distinct(match, field);
console.log(result);
```

@@ -360,3 +282,3 @@

```js
mquery().findOne().where('route').intersects(polygon).exec(function (err, docs){})
const docs = await mquery().findOne().where('route').intersects(polygon).exec()
```

@@ -378,3 +300,3 @@

-------------
---

@@ -697,3 +619,3 @@ ### all()

##### String syntax
#### String syntax

@@ -815,7 +737,7 @@ When passing a string, prefixing a path with `-` will flag that path as excluded. When a path does not have the `-` prefix, it is included.

// chaining
mquery()
.where('age').gte(21).lte(65)
.where({ 'name': /^vonderful/i })
.where('friends').slice(10)
.exec(callback)
await mquery()
.where('age').gte(21).lte(65)
.where({ 'name': /^vonderful/i })
.where('friends').slice(10)
.exec()
```

@@ -830,3 +752,3 @@

```js
query.$where('this.comments.length > 10 || this.name.length > 5').exec(callback)
await query.$where('this.comments.length > 10 || this.name.length > 5').exec()

@@ -840,3 +762,3 @@ query.$where(function () {

-----------
---

@@ -899,4 +821,2 @@ ### batchSize()

- `findOneAndUpdate()`
- `remove()`
- `update()`
- `updateOne()`

@@ -923,14 +843,2 @@ - `updateMany()`

### maxScan()
Specifies the maxScan option.
```js
query.maxScan(100)
```
_Cannot be used with `distinct()`._
[MongoDB documentation](http://docs.mongodb.org/manual/reference/operator/maxScan/)
### maxTime()

@@ -947,3 +855,2 @@

### skip()

@@ -1002,3 +909,3 @@

##### Preferences:
#### Preferences:

@@ -1019,3 +926,3 @@ - `primary` - (default) Read from primary only. Operations will produce an error if primary is unavailable. Cannot be combined with tags.

##### Preference Tags:
#### Preference Tags:

@@ -1032,3 +939,3 @@ To keep the separation of concerns between `mquery` and your driver

var preference = new ReadPref('secondary', [{ dc:'sf', s: 1 },{ dc:'ma', s: 2 }]);
mquery(..).read(preference).exec();
mquery(...).read(preference).exec();
```

@@ -1038,3 +945,2 @@

### readConcern()

@@ -1071,3 +977,3 @@

##### Read Concern Level:
#### Read Concern Level:

@@ -1100,4 +1006,2 @@ - `local` - The query returns from the instance with no guarantee guarantee that the data has been written to a majority of the replica set members (i.e. may be rolled back). (MongoDB 3.2+)

- `findOneAndUpdate()`
- `remove()`
- `update()`
- `updateOne()`

@@ -1116,3 +1020,3 @@ - `updateMany()`

##### Write Concern:
#### Write Concern:

@@ -1145,16 +1049,2 @@ writeConcern({ w: `<value>`, j: `<boolean>`, wtimeout: `<number>` }`)

### snapshot()
Specifies this query as a snapshot query.
```js
mquery().snapshot() // true
mquery().snapshot(true)
mquery().snapshot(false)
```
_Cannot be used with `distinct()`._
[MongoDB documentation](http://docs.mongodb.org/manual/reference/operator/snapshot/)
### tailable()

@@ -1185,4 +1075,2 @@

- `findOneAndUpdate()`
- `remove()`
- `update()`
- `updateOne()`

@@ -1230,14 +1118,2 @@ - `updateMany()`

### thunk()
Returns a thunk which when called runs the query's `exec` method passing the results to the callback.
```js
var thunk = mquery(collection).find({..}).thunk();
thunk(function(err, results) {
})
```
### merge(object)

@@ -1248,7 +1124,6 @@

```js
var drum = mquery({ type: 'drum' }).collection(instruments);
var redDrum = mquery({ color: 'red' }).merge(drum);
redDrum.count(function (err, n) {
console.log('there are %d red drums', n);
})
const drum = mquery({ type: 'drum' }).collection(instruments);
const redDrum = mquery({ color: 'red' }).merge(drum);
const n = await redDrum.count();
console.log('there are %d red drums', n);
```

@@ -1266,3 +1141,3 @@

##### options
#### setOptions() options

@@ -1273,7 +1148,5 @@ - [tailable](#tailable) *

- [skip](#skip) *
- [maxScan](#maxscan) *
- [maxTime](#maxtime) *
- [batchSize](#batchSize) *
- [batchSize](#batchsize) *
- [comment](#comment) *
- [snapshot](#snapshot) *
- [hint](#hint) *

@@ -1304,5 +1177,5 @@ - [collection](#collection): the collection to query against

- queryInfo contains information about the query:
- conditions: query conditions/criteria
- options: options such as sort, fields, etc
- doc: document being updated
- conditions: query conditions/criteria
- options: options such as sort, fields, etc
- doc: document being updated
- query is the query object

@@ -1355,9 +1228,7 @@

// use it!
greatMovies().count(function (err, n) {
console.log('There are %d great movies', n);
});
const n = await greatMovies().count();
console.log('There are %d great movies', n);
greatMovies().where({ name: /^Life/ }).select('name').find(function (err, docs) {
console.log(docs);
});
const docs = await greatMovies().where({ name: /^Life/ }).select('name').find();
console.log(docs);
```

@@ -1373,3 +1244,5 @@

DEBUG=mquery node yourprogram.js
```sh
DEBUG=mquery node yourprogram.js
```

@@ -1380,3 +1253,3 @@ Read the debug module documentation for more details.

#### ObjectIds
### ObjectIds

@@ -1397,3 +1270,3 @@ `mquery` clones query arguments before passing them to a `collection` method for execution.

`mquery` supports specifying [Read Preferences]() to control from which MongoDB node your query will read.
`mquery` supports specifying [Read Preferences](https://www.mongodb.com/docs/manual/core/read-preference/) to control from which MongoDB node your query will read.
The Read Preferences spec also support specifying tags. To pass tags, some

@@ -1405,8 +1278,10 @@ drivers (Node.js driver) require passing a special constructor that handles both the read preference and its tags.

- mongo shell compatibility
- browser compatibility
- mongo shell compatibility
- browser compatibility
## Installation
$ npm install mquery
```sh
npm install mquery
```

@@ -1416,2 +1291,1 @@ ## License

[MIT](https://github.com/aheckmann/mquery/blob/master/LICENSE)

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc