monastery 3.0.16 → 3.0.17

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/changelog.md CHANGED
@@ -2,6 +2,8 @@
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
+ ### [3.0.17](https://github.com/boycce/monastery/compare/3.0.16...3.0.17) (2024-05-02)
6
+
5
7
  ### [3.0.16](https://github.com/boycce/monastery/compare/3.0.15...3.0.16) (2024-05-02)
6
8
 
7
9
  ### [3.0.15](https://github.com/boycce/monastery/compare/3.0.14...3.0.15) (2024-05-01)
package/lib/model-crud.js CHANGED
@@ -465,6 +465,8 @@ Model.prototype._getProjectionFromProject = function (customProject) {
465
465
  o[v.replace(/^-/, '')] = v.match(/^-/)? 0 : 1
466
466
  return o
467
467
  }, {})
468
+ } else if (util.isObject(customProject)) {
469
+ projection = customProject
468
470
  }
469
471
  return projection
470
472
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "monastery",
3
3
  "description": "⛪ A simple, straightforward MongoDB ODM",
4
4
  "author": "Ricky Boyce",
5
- "version": "3.0.16",
5
+ "version": "3.0.17",
6
6
  "license": "MIT",
7
7
  "repository": "github:boycce/monastery",
8
8
  "homepage": "https://boycce.github.io/monastery/",
@@ -218,18 +218,26 @@ test('find project basic', async () => {
218
218
  }})
219
219
 
220
220
  // pass: test inclusion of projections via native mongodb project option
221
- let find1 = await user.findOne({
221
+ let find11 = await user.findOne({
222
222
  query: user1._id,
223
- project: ['animal.name', 'animals.name'],
223
+ project: {'animal.name': 1, 'animals.name': 1},
224
224
  })
225
- expect(find1).toEqual({
225
+ const find11Expected = {
226
226
  _id: user1._id,
227
227
  animal: { name: 'max' },
228
228
  animals: [
229
229
  { name: 'ponyo' },
230
230
  { name: 'freddy' },
231
231
  ],
232
+ }
233
+ expect(find11).toEqual(find11Expected)
234
+
235
+ // pass: test inclusion of projections via native mongodb project option
236
+ let find1 = await user.findOne({
237
+ query: user1._id,
238
+ project: ['animal.name', 'animals.name'],
232
239
  })
240
+ expect(find1).toEqual(find11Expected)
233
241
 
234
242
  // pass: test exclusion of projections via native mongodb project option
235
243
  let find2 = await user.findOne({