monastery 1.37.0 → 1.37.3

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,27 @@
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
+ ### [1.37.3](https://github.com/boycce/monastery/compare/1.37.2...1.37.3) (2022-06-17)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * test ([dad21ad](https://github.com/boycce/monastery/commit/dad21ad9c014a45ccc50a4755daa12941d6b7465))
11
+
12
+ ### [1.37.2](https://github.com/boycce/monastery/compare/1.37.1...1.37.2) (2022-06-13)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * changed the default awsAcl from public-read to private ([ba383b5](https://github.com/boycce/monastery/commit/ba383b5f363dafe3b893e08de1a124b7ce96df44))
18
+
19
+ ### [1.37.1](https://github.com/boycce/monastery/compare/1.37.0...1.37.1) (2022-06-13)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * add _id to upserted document ([a78512f](https://github.com/boycce/monastery/commit/a78512f16b39422160756fe91ef4d4a3239f5890))
25
+
5
26
  ## [1.37.0](https://github.com/boycce/monastery/compare/1.36.3...1.37.0) (2022-06-12)
6
27
 
7
28
 
package/docs/readme.md CHANGED
@@ -93,7 +93,7 @@ Coming soon...
93
93
  - ~~Whitelisting a parent will remove any previously blacklisted children~~
94
94
  - ~~Blacklist/project works the same across find/insert/update/validate~~
95
95
  - Automatic embedded document ids/createdAt/updatedAt fields
96
- - Remove ACL default 'public read'
96
+ - ~~Change ACL default 'public read' to 'private'~~
97
97
  - ~~Public db.arrayWithSchema method~~
98
98
  - Global after/before hooks
99
99
  - docs: Make the implicit ID query conversion more apparent
package/lib/model-crud.js CHANGED
@@ -255,7 +255,11 @@ module.exports = {
255
255
  // Update
256
256
  let update = await this['_' + type](opts.query, operators, util.omit(opts, this._queryOptions))
257
257
  if (type == 'findOneAndUpdate') response = update
258
- else if (update.n) response = Object.assign(Object.create({ _output: update }), operators['$set']||{})
258
+ else if (update.n) response = Object.assign(
259
+ Object.create({ _output: update }),
260
+ operators['$set'] || {},
261
+ (update.upserted||[])[0] ? { _id: update.upserted[0]._id } : {},
262
+ )
259
263
 
260
264
  // Hook: afterUpdate (doesn't have access to validated data)
261
265
  if (response) await util.runSeries(this.afterUpdate.map(f => f.bind(opts, response)))
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "monastery",
3
3
  "description": "⛪ A straight forward MongoDB ODM built around Monk",
4
4
  "author": "Ricky Boyce",
5
- "version": "1.37.0",
5
+ "version": "1.37.3",
6
6
  "license": "MIT",
7
7
  "repository": "github:boycce/monastery",
8
8
  "homepage": "https://boycce.github.io/monastery/",
@@ -25,7 +25,7 @@ let plugin = module.exports = {
25
25
  }
26
26
 
27
27
  // Settings
28
- this.awsAcl = options.awsAcl || 'public-read'
28
+ this.awsAcl = options.awsAcl || 'private' // default
29
29
  this.awsBucket = options.awsBucket
30
30
  this.awsAccessKeyId = options.awsAccessKeyId
31
31
  this.awsSecretAccessKey = options.awsSecretAccessKey
package/test/crud.js CHANGED
@@ -201,6 +201,15 @@ module.exports = function(monastery, opendb) {
201
201
  name: 'Martin Luther3'
202
202
  }
203
203
  ])
204
+
205
+ // Upsert
206
+ let newId = db.id()
207
+ await expect(user.update({ query: newId, data: { name: 'Martin Luther3' }, upsert: true }))
208
+ .resolves.toEqual({ _id: newId, name: 'Martin Luther3' }) // inserted
209
+
210
+ await expect(user.update({ query: inserted._id, data: { name: 'Martin Luther4' }, upsert: true }))
211
+ .resolves.toEqual({ name: 'Martin Luther4' }) // updated
212
+
204
213
  db.close()
205
214
  })
206
215
 
@@ -641,7 +641,7 @@ module.exports = function(monastery, opendb) {
641
641
  app.use(upload({ limits: { fileSize: 1000 * 480, files: 10 }}))
642
642
 
643
643
  // Basic tests
644
- expect(plugin.awsAcl).toEqual('public-read')
644
+ expect(plugin.awsAcl).toEqual('private')
645
645
  expect(plugin.filesize).toEqual(undefined)
646
646
  expect(plugin.formats).toEqual(['bmp', 'gif', 'jpg', 'jpeg', 'png', 'tiff'])
647
647
  expect(plugin.getSignedUrl).toEqual(undefined)
@@ -688,7 +688,7 @@ module.exports = function(monastery, opendb) {
688
688
  // S3 options
689
689
  expect(response[1]).toEqual([
690
690
  [{
691
- ACL: 'public-read',
691
+ ACL: 'private',
692
692
  Body: expect.any(Object),
693
693
  Bucket: 'fake',
694
694
  Key: expect.stringMatching(/^full\/.*png$/),