monastery 2.2.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.json CHANGED
@@ -8,9 +8,11 @@
8
8
  "eslint:recommended"
9
9
  ],
10
10
  "globals": {
11
+ // jest globals
11
12
  "test": true,
12
13
  "expect": true,
13
- "oid": true
14
+ "afterAll": true,
15
+ "beforeAll": true
14
16
  },
15
17
  "parserOptions": {
16
18
  "ecmaFeatures": {
@@ -22,6 +24,13 @@
22
24
  "plugins": [],
23
25
  "rules": {
24
26
  "brace-style": ["error", "1tbs", { "allowSingleLine": true }],
27
+ "comma-dangle": ["error", {
28
+ "arrays": "always-multiline",
29
+ "objects": "always-multiline",
30
+ "imports": "always-multiline",
31
+ "exports": "always-multiline",
32
+ "functions": "never"
33
+ }],
25
34
  "max-len": ["error", { "code": 125, "ignorePattern": "^\\s*<(rect|path|line)\\s" }],
26
35
  "no-prototype-builtins": "off",
27
36
  "no-unused-vars": ["error", { "args": "none" }],
package/changelog.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- ### [2.2.3](https://github.com/boycce/monastery/compare/2.2.2...2.2.3) (2024-04-28)
5
+ ## [3.0.0](https://github.com/boycce/monastery/compare/2.2.2...3.0.0) (2024-04-28)
6
6
 
7
7
  ### [2.2.2](https://github.com/boycce/monastery/compare/2.2.1...2.2.2) (2024-04-07)
8
8
 
package/docs/_config.yml CHANGED
@@ -1,11 +1,11 @@
1
1
  remote_theme: boycce/github-docs
2
2
  title: Monastery
3
- description: A straight forward MongoDB ODM built upon MonkJS
3
+ description: A simple, straightforward MongoDB ODM
4
4
  github_url: "https://github.com/boycce/monastery"
5
5
  port: 4001
6
6
  basedir: "docs"
7
7
 
8
- # Aux links for the naviation.
8
+ # Aux links for the navigation.
9
9
  aux_links:
10
10
  "Monastery on GitHub":
11
11
  - "//github.com/boycce/monastery"
Binary file
@@ -161,8 +161,7 @@ fieldType: {
161
161
  index: 'text'
162
162
 
163
163
  // You can also pass an object if you need to use mongodb's index options
164
- // https://docs.mongodb.com/manual/reference/command/createIndexes/
165
- // https://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#createIndexes
164
+ // https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#createIndex
166
165
  index: { type: 1, ...(any mongodb index option) },
167
166
 
168
167
  }
@@ -6,26 +6,25 @@ has_children: true
6
6
 
7
7
  # Manager
8
8
 
9
- Monastery constructor, same as the [monk constructor](https://automattic.github.io/monk/docs/manager/).
9
+ Monastery manager constructor.
10
10
 
11
11
  ### Arguments
12
12
 
13
- `uri` *(string\|array)*: A [mongo connection string URI](https://docs.mongodb.com/manual/reference/connection-string/). Replica sets can be an array or comma separated.
13
+ `uri` *(string\|array)*: A [mongo connection string URI](https://www.mongodb.com/docs/v5.0/reference/connection-string/). Replica sets can be an array or comma separated.
14
14
 
15
15
  [`options`] *(object)*:
16
16
  - [`hideWarnings=false`] *(boolean)*: hide monastery warnings
17
17
  - [`hideErrors=false`] *(boolean)*: hide monastery errors
18
18
  - [`defaultObjects=false`] *(boolean)*: when [inserting](../model/insert.html#defaults-example), undefined embedded documents and arrays are defined
19
19
  - [`nullObjects=false`] *(boolean)*: embedded documents and arrays can be set to null or an empty string (which gets converted to null). You can override this per field via `nullObject: true`.
20
+ - [`promise=false`] *(boolean)*: return a promise instead of the manager instance
20
21
  - [`timestamps=true`] *(boolean)*: whether to use [`createdAt` and `updatedAt`](../definition), this can be overridden per operation
21
22
  - [`useMilliseconds=false`] *(boolean)*: by default the `createdAt` and `updatedAt` fields that get created automatically use unix timestamps in seconds, set this to true to use milliseconds instead.
22
- - [`mongo options`](http://mongodb.github.io/node-mongodb-native/3.2/reference/connecting/connection-settings/)...
23
-
24
- [`callback`] *(function)*: You may optionally specify a callback which will be called once the connection to the mongo database is opened or throws an error.
23
+ - [`mongo options`](https://mongodb.github.io/node-mongodb-native/5.9/interfaces/MongoClientOptions.html)...
25
24
 
26
25
  ### Returns
27
26
 
28
- A monk manager instance with additional Monastery methods, i.e. `model` `models`
27
+ A manager instance.
29
28
 
30
29
  ### Example
31
30
 
@@ -40,16 +39,25 @@ const db = monastery('localhost/mydb,192.168.1.1') // replica set
40
39
  ```
41
40
 
42
41
  ```js
42
+ // You can wait for the connection (which is not required before calling methods)
43
43
  import monastery from 'monastery'
44
- monastery('localhost/mydb,192.168.1.1').then((db) => {
45
- // db is the connected instance of the Manager
46
- }).catch((err) => {
47
- // error connecting to the database
48
- })
44
+ const db = await monastery('localhost/mydb,192.168.1.1', { promise: true })
49
45
  ```
50
46
 
47
+ ```js
48
+ // You can listen for connection errors using our `catch` hook
49
+ import monastery from 'monastery'
50
+ const db = monastery('localhost/mydb,192.168.1.1').catch(err => {})
51
+ ```
52
+
53
+ ### Properties
54
+
55
+ - `manager.db`: Raw Mongo db instance
56
+ - `manager.client`: Raw Mongo client instance
57
+
51
58
  ### Methods
52
59
 
60
+ - `manager.catch(Function)`: Catches connection errors
53
61
  - `manager.id(<String|ObjectId>)`: Create or convert a valid MongoDB ObjectId string into an ObjectId
54
62
  - `manager.isId(String|ObjectId)`: Checks if the passed variable is a valid MongoDB ObjectId or ObjectId string
55
63
  - `manager.model()`: [see model](./model.html)
@@ -19,7 +19,7 @@ A [model](../model) instance, the model instance will also be avaliable at:
19
19
 
20
20
  ```js
21
21
  db.user
22
- db.model.user
22
+ db.models.user
23
23
  ```
24
24
 
25
25
  ### Example
@@ -13,10 +13,10 @@ Setup model definitions from a folder location
13
13
 
14
14
  ### Returns
15
15
 
16
- A promise with an array of [model](../model) instances, the model instances will also be avaliable at:
16
+ A promise with an array of [model](../model) instances, the model instances will also be available at:
17
17
  ```js
18
18
  db.{model-name}
19
- db.model.{model-name}
19
+ db.models.{model-name}
20
20
  ```
21
21
 
22
22
  ### Example
@@ -36,5 +36,4 @@ export default { // Make sure the model definition is exported as the default
36
36
 
37
37
  ```js
38
38
  await db.models(__dirname + "models")
39
- db.user.insert()
40
39
  ```
@@ -0,0 +1,289 @@
1
+ ---
2
+ title: ...raw methods
3
+ parent: Model
4
+ ---
5
+
6
+ # Raw Methods
7
+
8
+ These MongoDB collection methods are made available if you need to test or run any method without hooks or Monastery argument/return processing.
9
+
10
+ These methods can be accessed via the `model._*`.
11
+
12
+ ## Returns
13
+
14
+ All methods return a promise.
15
+
16
+ ## Methods
17
+
18
+ * model.[_aggregate](#model._aggregate)
19
+ * model.[_bulkWrite](#model._bulkWrite)
20
+ * model.[_count](#model._count)
21
+ * model.[_createIndex](#model._createIndex)
22
+ * model.[_createIndexes](#model._createIndexes)
23
+ * model.[_distinct](#model._distinct)
24
+ * model.[_drop](#model._drop)
25
+ * model.[_dropIndex](#model._dropIndex)
26
+ * model.[_dropIndexes](#model._dropIndexes)
27
+ * model.[_find](#model._find)
28
+ * model.[_findOne](#model._findOne)
29
+ * model.[_findOneAndDelete](#model._findOneAndDelete)
30
+ * model.[_findOneAndUpdate](#model._findOneAndUpdate)
31
+ * model.[_indexes](#model._indexes)
32
+ * model.[_indexInformation](#model._indexInformation)
33
+ * model.[_insert](#model._insert)
34
+ * model.[_remove](#model._remove)
35
+ * model.[_stats](#model._stats)
36
+ * model.[_update](#model._update)
37
+
38
+ ### [`model._aggregate`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#aggregate)
39
+
40
+ Execute an aggregation framework pipeline against the collection. Arguments:
41
+
42
+ 1. `Pipeline` *(array)*
43
+ 2. `[Options]` *(object)*
44
+
45
+ ```js
46
+ await users.aggregate([
47
+ { $project : { author : 1, tags : 1 }},
48
+ { $unwind : "$tags" },
49
+ { $group : { _id : { tags : "$tags" }}}
50
+ ])
51
+ ```
52
+
53
+ ### [`model._bulkWrite`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#bulkWrite)
54
+
55
+ Perform a bulkWrite operation without a fluent API. Arguments:
56
+
57
+ 1. `Operations` *(array)* - Bulk operations to perform
58
+ 2. `[Options]` *(object)*
59
+
60
+ Legal operation types are:
61
+
62
+ ```js
63
+ await users._bulkWrite([
64
+ { insertOne: { document: { a: 1 } } },
65
+ { updateOne: { filter: {a:2}, update: {$set: {a:2}}, upsert:true } },
66
+ { updateMany: { filter: {a:2}, update: {$set: {a:2}}, upsert:true } },
67
+ { deleteOne: { filter: {c:1} } },
68
+ { deleteMany: { filter: {c:1} } },
69
+ { replaceOne: { filter: {c:3}, replacement: {c:4}, upsert:true}}
70
+ ])
71
+ ```
72
+
73
+ ### [`model._count`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#count)
74
+
75
+ Returns the count of documents that would match a find() query. The method uses collection.countDocuments() in the mongo driver. Arguments:
76
+
77
+ 1. `[Filter]` *(string|objectId|object)*
78
+ 2. `[Options]` *(object)*
79
+
80
+ ```js
81
+ await users._count({ name: 'foo' })
82
+ await users._count('id') // a bit useless but consistent with the rest of the API
83
+ await users._count()
84
+ ```
85
+
86
+ If you need to get a fast order of magnitude of the count of all documents in your collection, you can use the estimate option.
87
+
88
+ ```js
89
+ await users._count({}, { estimate: true }) // Filter is ignored
90
+ ```
91
+
92
+ ### [`model._createIndex`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#createIndex)
93
+
94
+ Creates an index on the db and collection collection. Arguments:
95
+
96
+ 1. `IndexSpec` *(string|array|object)* - The field name or index specification to create an index for
97
+ 2. `[Options]` *(object)*
98
+
99
+ ```js
100
+ await users.createIndex({ a: 1, b: -1 });
101
+ // Alternate syntax for { c: 1, d: -1 } that ensures order of indexes
102
+ await users.createIndex([ [c, 1], [d, -1] ]);
103
+ // Equivalent to { e: 1 }
104
+ await users.createIndex('e');
105
+ // Equivalent to { f: 1, g: 1 }
106
+ await users.createIndex(['f', 'g'])
107
+ // Equivalent to { h: 1, i: -1 }
108
+ await users.createIndex([ { h: 1 }, { i: -1 } ]);
109
+ // Equivalent to { j: 1, k: -1, l: 2d }
110
+ await users.createIndex(['j', ['k', -1], { l: '2d' }])
111
+ ```
112
+
113
+ ### [`model._createIndexes`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#createIndexes)
114
+
115
+ Creates multiple indexes in the collection. Arguments:
116
+
117
+ 1. `IndexSpec` *(array<IndexSpec>)*- The field names or index specifications to create an indexes for
118
+ 2. `[Options]` *(object)*
119
+
120
+ ```js
121
+ await users.createIndexes([
122
+ // Simple index on field fizz
123
+ { key: { fizz: 1 } }
124
+ // wildcard index
125
+ { key: { '$**': 1 } },
126
+ // named index on darmok and jalad
127
+ { key: { darmok: 1, jalad: -1 } name: 'tanagra' }
128
+ ])
129
+ ```
130
+
131
+ ### [`model._distinct`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#distinct)
132
+
133
+ Returns a list of distinct values for the given key across a collection. Arguments:
134
+
135
+ 1. `Key` *(string)*
136
+ 2. `[Filter]` *(string|objectId|object)*
137
+ 3. `[Options]` *(object)*
138
+
139
+ ```js
140
+ await users._distinct('name')
141
+ ```
142
+
143
+ ### [`model._drop`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#drop)
144
+
145
+ Drops the entire collection. Arguments: `None`
146
+
147
+ ```js
148
+ await users._drop()
149
+ ```
150
+
151
+ ### [`model._dropIndex`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#dropIndex)
152
+
153
+ Drops an index on the collection. Arguments:
154
+
155
+ 1. `IndexName` *(string)*
156
+ 2. `[Options]` *(object)*
157
+
158
+ ```js
159
+ await users._dropIndex('name')
160
+ await users._dropIndex('name.last')
161
+ ```
162
+
163
+ ### [`model._dropIndexes`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#dropIndexes)
164
+
165
+ Drops all indexes from the collection. Arguments: `None`
166
+
167
+ ```js
168
+ await users._dropIndexes()
169
+ ```
170
+
171
+ ### [`model._find`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#find)
172
+
173
+ Finds documents in the collection. Arguments:
174
+
175
+ 1. `[Filter]` *(string|objectId|object)*
176
+ 2. `[Options]` *(object)*
177
+
178
+ ```js
179
+ await users._find()
180
+ await users._find({ name: 'John' })
181
+ await users._find({}, { projection: { name: 1 } }) // only the name field will be selected
182
+ await users._find({}, { rawCursor: true }) // returns raw mongo cursor
183
+ await users._find({}, {
184
+ stream: ((doc, { close, pause, resume }) => {
185
+ // the users are streaming here
186
+ // call `close()` to stop the stream
187
+ })
188
+ })
189
+ ```
190
+
191
+ ### [`model._findOne`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#findOne)
192
+
193
+ Fetches the first document that matches the filter. Arguments:
194
+
195
+ 1. `[Filter]` *(string|objectId|object)*
196
+ 2. `[Options]` *(object)*
197
+
198
+ ```js
199
+ await users._findOne({ name: 'John' })
200
+ await users._findOne({}, { projection: { name: 1 } }) // only the name field will be selected
201
+ ```
202
+
203
+ ### [`model._findOneAndDelete`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#findOneAndDelete)
204
+
205
+ Find a document and delete it in one atomic operation. Requires a write lock for the duration of the operation. Arguments:
206
+
207
+ 1. `[Filter]` *(string|objectId|object)*
208
+ 2. `[Options]` *(object)*
209
+
210
+ ```js
211
+ await users._findOneAndDelete({ name: 'John' })
212
+ ```
213
+
214
+ ### [`model._findOneAndUpdate`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#findOneAndUpdate)
215
+
216
+ Find a document and update it in one atomic operation. Requires a write lock for the duration of the operation. Arguments:
217
+
218
+ 1. `Filter` *(string|objectId|object)*
219
+ 2. `Update` *(object)*
220
+ 3. `[Options]` *(object)*
221
+
222
+ ```js
223
+ await users._findOneAndUpdate({ name: 'John' }, { $set: { age: 30 } })
224
+ ```
225
+
226
+ ### [`model._indexInformation`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#indexInformation)
227
+
228
+ Retrieves this collections index info. Argument(s):
229
+
230
+ 1. `[Options]` *(object)*
231
+
232
+ ```js
233
+ await users._indexInformation()
234
+ ```
235
+
236
+ ### [`model._indexes`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#indexes)
237
+
238
+ Lists all indexes on the collection. Argument(s):
239
+
240
+ 1. `[Options]` *(object)*
241
+
242
+ ```js
243
+ await users._indexes()
244
+ ```
245
+
246
+ ### [`model._insert`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#insertMany)
247
+
248
+ Inserts one or more documents into the collection. Arguments:
249
+
250
+ 1. `Doc` *(object|array)* - one or many documents
251
+ 2. `[Options]` *(object)*
252
+
253
+ ```js
254
+ await users._insert({ name: 'John', age: 30 })
255
+ await users._insert([{ name: 'John', age: 30 }, { name: 'Bill', age: 32 }])
256
+ ```
257
+
258
+ ### [`model._remove`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#deleteMany)
259
+
260
+ Removes one or more document(s) from the collection. Arguments:
261
+
262
+ 1. `Filter` *(string|objectId|object)*
263
+ 2. `[Options]` *(object)*
264
+
265
+ ```js
266
+ await users._remove({ name: 'John' })
267
+ ```
268
+
269
+ ### [`model._stats`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#stats)
270
+
271
+ Returns statistics about the collection. Arguments:
272
+
273
+ 1. `[Options]` *(object)*
274
+
275
+ ```js
276
+ await users._stats()
277
+ ```
278
+
279
+ ### [`model._update`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#updateMany)
280
+
281
+ Updates one or more document(s) from the collection. Arguments:
282
+
283
+ 1. `Filter` *(string|objectId|object)*
284
+ 1. `Update` *(object)*
285
+ 2. `[Options]` *(object)*
286
+
287
+ ```js
288
+ await users._update({ name: 'John' }, { $set: { age: 30 } })
289
+ ```
@@ -0,0 +1,25 @@
1
+ ---
2
+ title: count
3
+ parent: Model
4
+ ---
5
+
6
+ # `model.count`
7
+
8
+ Count document(s) in a collection
9
+
10
+ ### Arguments
11
+
12
+ `options` *(object)*
13
+
14
+ - `query` *(object\|id)*: [`MongoDB query document`](https://www.mongodb.com/docs/v5.0/tutorial/query-documents/), or id
15
+ - [[`any mongodb option`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#count)] *(any)*
16
+
17
+ ### Returns
18
+
19
+ A promise
20
+
21
+ ### Example
22
+
23
+ ```js
24
+ await user.count({ query: { name: "Martin Luther" }}) // 4
25
+ ```
@@ -5,25 +5,23 @@ parent: Model
5
5
 
6
6
  # `model.find`
7
7
 
8
- Find document(s) in a collection and call the model hook: `afterFind`
8
+ Find document(s) in a collection, and call the model hook: `afterFind`
9
9
 
10
10
  ### Arguments
11
11
 
12
12
  `options` *(object)*
13
13
 
14
- - `query` *(object\|id)*: [`MongoDB query document`](https://www.mongodb.com/docs/v4.4/tutorial/query-documents/), or id
14
+ - `query` *(object\|id)*: [`MongoDB query document`](https://www.mongodb.com/docs/v5.0/tutorial/query-documents/), or id
15
15
  - [[`blacklist`](#blacklisting)] *(array\|string\|false)*: augment `definition.findBL`. `false` will remove all blacklisting
16
16
  - [`getSignedUrls`] *(boolean)*: get signed urls for all image objects
17
17
  - [[`populate`](#populate)] *(array)*
18
18
  - [`project`] *(string\|array\|object)*: return only these fields, ignores blacklisting
19
19
  - [`sort`] *(string\|array\|object)*: same as the mongodb option, but allows string parsing e.g. 'name', 'name:1'
20
- - [[`any mongodb option`](http://mongodb.github.io/node-mongodb-native/3.2/api/Collection.html#find)] *(any)*
21
-
22
- [`callback`] *(function)*: pass instead of return a promise
20
+ - [[`any mongodb option`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#find)] *(any)*
23
21
 
24
22
  ### Returns
25
23
 
26
- A promise if no callback is passed in.
24
+ A promise
27
25
 
28
26
  ### Example
29
27
 
@@ -81,9 +79,7 @@ user.find({ query: {...}, populate: ['myBooks.book'] })
81
79
 
82
80
  ### Custom Populate Query
83
81
 
84
- If you would like more control you can either use monk's native
85
- [aggregate](https://automattic.github.io/monk/docs/collection/aggregate.html) function via
86
- `user._aggregate`, or simply pass a MongoDB lookup object to populate. When passing a lookup object, the
82
+ If you would like more control you can either use Mongo's `aggregate` method via [`model._aggregate`](./...rawMethods), or simply pass a MongoDB lookup object to populate. When passing a lookup object, the
87
83
  populated field still needs to be defined in `definition.fields` if you want to call any related hooks,
88
84
  and prune any blacklisted fields. See the examples below,
89
85
 
@@ -13,7 +13,7 @@ Same argument signature as [`model.find`](./find).
13
13
 
14
14
  ### Returns
15
15
 
16
- A promise if no callback is passed in.
16
+ A promise
17
17
 
18
18
  ### Example
19
19
 
@@ -13,7 +13,7 @@ Same argument signatures as [`model.find`](./find) and [`model.update`](./update
13
13
 
14
14
  ### Returns
15
15
 
16
- A promise if no callback is passed in.
16
+ A promise
17
17
 
18
18
  ### Example
19
19
 
@@ -8,35 +8,10 @@ has_children: true
8
8
 
9
9
  Created via [`manager.model`](../manager/model).
10
10
 
11
- #### Monk collection instance operators
11
+ ### Properties
12
12
 
13
- Additionally models inherit most of the [monk collection](https://automattic.github.io/monk/docs/collection/) instance operators which are available under `model`.
13
+ You can access the following properties from each model:
14
14
 
15
- * model.[_aggregate](https://automattic.github.io/monk/docs/collection/aggregate.html)
16
- * model.[_bulkWrite](https://automattic.github.io/monk/docs/collection/bulkWrite.html)
17
- * model.[_count](https://automattic.github.io/monk/docs/collection/count.html)
18
- * model.[_distinct](https://automattic.github.io/monk/docs/collection/distinct.html)
19
- * model.[_drop](https://automattic.github.io/monk/docs/collection/drop.html)
20
- * model.[_dropIndex](https://automattic.github.io/monk/docs/collection/dropIndex.html)
21
- * model.[_dropIndexes](https://automattic.github.io/monk/docs/collection/dropIndexes.html)
22
- * model.[_ensureIndex](https://automattic.github.io/monk/docs/collection/ensureIndex.html)
23
- * model.[_find](https://automattic.github.io/monk/docs/collection/find.html)
24
- * model.[_findOne](https://automattic.github.io/monk/docs/collection/findOne.html)
25
- * model.[_findOneAndDelete](https://automattic.github.io/monk/docs/collection/findOneAndDelete.html)
26
- * model.[_findOneAndUpdate](https://automattic.github.io/monk/docs/collection/findOneAndUpdate.html)
27
- * model.[_geoHaystackSearch](https://automattic.github.io/monk/docs/collection/geoHaystackSearch.html)
28
- * model.[_geoNear](https://automattic.github.io/monk/docs/collection/geoNear.html)
29
- * model.[_group](https://automattic.github.io/monk/docs/collection/group.html)
30
- * model.[_indexes](https://automattic.github.io/monk/docs/collection/indexes.html)
31
- * model.[_insert](https://automattic.github.io/monk/docs/collection/insert.html)
32
- * model.[_mapReduce](https://automattic.github.io/monk/docs/collection/mapReduce.html)
33
- * model.[_remove](https://automattic.github.io/monk/docs/collection/remove.html)
34
- * model.[_stats](https://automattic.github.io/monk/docs/collection/stats.html)
35
- * model.[_update](https://automattic.github.io/monk/docs/collection/update.html)
36
-
37
- #### Monk collection
38
-
39
- If you wish to access the raw monk collection, you can do so via:
40
- ```js
41
- model._collection
42
- ```
15
+ - `model.manager`: Monastery manager instance
16
+ - `model.collection`: Monastery collection instance
17
+ - `model.collection.col`: Raw Mongo collection
@@ -16,19 +16,17 @@ Validate and insert document(s) in a collection and calls model hooks: `beforeIn
16
16
  - [`project`] *(string\|array\|object)*: project these fields, ignores blacklisting
17
17
  - [`skipValidation`] (string\|array\|boolean): skip validation for these field name(s), or `true` for all fields
18
18
  - [`timestamps`] *(boolean)*: whether `createdAt` and `updatedAt` are automatically inserted, defaults to `manager.timestamps`
19
- - [[`any mongodb option`](http://mongodb.github.io/node-mongodb-native/3.2/api/Collection.html#insert)] *(any)*
20
-
21
- [`callback`] *(function)*: pass instead of return a promise
19
+ - [[`any mongodb option`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#insertMany)] *(any)*
22
20
 
23
21
  ### Returns
24
22
 
25
- A promise if no callback is passed in.
23
+ A promise
26
24
 
27
25
  ### Example
28
26
 
29
27
  ```js
30
- user.insert({ data: { name: 'Martin Luther' }})
31
- user.insert({ data: [{ name: 'Martin Luther' }, { name: 'Bruce Lee' }]})
28
+ await user.insert({ data: { name: 'Martin Luther' }})
29
+ await user.insert({ data: [{ name: 'Martin Luther' }, { name: 'Bruce Lee' }]})
32
30
  ```
33
31
 
34
32
  ### Blacklisting
@@ -11,19 +11,17 @@ Remove document(s) in a collection and calls model hooks: `beforeRemove`, `afte
11
11
 
12
12
  `options` *(object)*
13
13
 
14
- - `query` *(object\|id)*: [`MongoDB query document`](https://www.mongodb.com/docs/v4.4/tutorial/query-documents/), or id
14
+ - `query` *(object\|id)*: [`MongoDB query document`](https://www.mongodb.com/docs/v5.0/tutorial/query-documents/), or id
15
15
  - [`sort`] *(string\|object\|array)*: same as the mongodb option, but allows for string parsing e.g. 'name', 'name:1'
16
16
  - [`multi`] *(boolean)*: set to false remove only the first document that match the query criteria
17
- - [[`any mongodb option`](http://mongodb.github.io/node-mongodb-native/3.2/api/Collection.html#remove)] *(any)*
18
-
19
- [`callback`] *(function)*: pass instead of return a promise
17
+ - [[`any mongodb option`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#deleteMany)] *(any)*
20
18
 
21
19
  ### Returns
22
20
 
23
- A promise if no callback is passed in.
21
+ A promise
24
22
 
25
23
  ### Example
26
24
 
27
25
  ```js
28
- user.remove({ query: { name: "Martin Luther" }})
26
+ await user.remove({ query: { name: "Martin Luther" }})
29
27
  ```
@@ -11,25 +11,23 @@ Update document(s) in a collection and calls model hooks: `beforeUpdate`, `afte
11
11
 
12
12
  `options` *(object)*
13
13
 
14
- - `query` *(object\|id)*: [`MongoDB query document`](https://www.mongodb.com/docs/v4.4/tutorial/query-documents/), or id
14
+ - `query` *(object\|id)*: [`MongoDB query document`](https://www.mongodb.com/docs/v5.0/tutorial/query-documents/), or id
15
15
  - [`data`](#data) *(object)* - data that's validated against the model fields (always wrapped in `{ $set: .. }`)
16
16
  - [[`blacklist`](#blacklisting)]*(array\|string\|false)*: augment `definition.updateBL`. `false` will remove all blacklisting
17
17
  - [`project`] *(string\|array\|object)*: project these fields, ignores blacklisting
18
18
  - [`skipValidation`] (string\|array\|boolean): skip validation for these field name(s), or `true` for all fields
19
19
  - [`sort`] *(string\|object\|array)*: same as the mongodb option, but allows for string parsing e.g. 'name', 'name:1'
20
20
  - [`timestamps`] *(boolean)*: whether `updatedAt` is automatically updated, defaults to the `manager.timestamps` value
21
- - [[`any mongodb option`](http://mongodb.github.io/node-mongodb-native/3.2/api/Collection.html#update)] *(any)*
22
-
23
- [`callback`] *(function)*: pass instead of return a promise
21
+ - [[`any mongodb option`](https://mongodb.github.io/node-mongodb-native/5.9/classes/Collection.html#updateMany)] *(any)*
24
22
 
25
23
  ### Returns
26
24
 
27
- A promise if no callback is passed in.
25
+ A promise
28
26
 
29
27
  ### Example
30
28
 
31
29
  ```js
32
- user.update({ query: { name: 'foo' }, data: { name: 'bar' }})
30
+ await user.update({ query: { name: 'foo' }, data: { name: 'bar' }})
33
31
  ```
34
32
 
35
33
  ### Data