monastery 3.5.5 → 3.5.7
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 +4 -0
- package/docs/definition/index.md +1 -1
- package/docs/model/find.md +3 -6
- package/docs/readme.md +3 -1
- package/lib/manager.js +9 -4
- package/package.json +1 -1
- package/test/collection.js +2 -2
- package/test/manager.js +4 -4
package/changelog.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
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.5.7](https://github.com/boycce/monastery/compare/3.5.6...3.5.7) (2025-09-16)
|
|
6
|
+
|
|
7
|
+
### [3.5.6](https://github.com/boycce/monastery/compare/3.5.5...3.5.6) (2025-06-15)
|
|
8
|
+
|
|
5
9
|
### [3.5.5](https://github.com/boycce/monastery/compare/3.5.4...3.5.5) (2025-06-14)
|
|
6
10
|
|
|
7
11
|
### [3.5.4](https://github.com/boycce/monastery/compare/3.5.3...3.5.4) (2025-06-12)
|
package/docs/definition/index.md
CHANGED
|
@@ -147,7 +147,7 @@ fieldType: {
|
|
|
147
147
|
|
|
148
148
|
### MongoDB indexes
|
|
149
149
|
|
|
150
|
-
You are able to
|
|
150
|
+
You are able to define MongoDB indexes via the `index` field option, these are automatically on initialisation. **Note, Monastery doesn't delete old indexes**.
|
|
151
151
|
|
|
152
152
|
```js
|
|
153
153
|
fieldType: {
|
package/docs/model/find.md
CHANGED
|
@@ -123,12 +123,9 @@ user.find({
|
|
|
123
123
|
as: 'myBooks',
|
|
124
124
|
from: 'book',
|
|
125
125
|
let: { userId: '$_id' },
|
|
126
|
-
pipeline: [
|
|
127
|
-
$match: {
|
|
128
|
-
|
|
129
|
-
$eq: ['$bookOwnerId', '$$userId']
|
|
130
|
-
}
|
|
131
|
-
}
|
|
126
|
+
pipeline: [
|
|
127
|
+
{ $match: { $expr: { $eq: ['$bookOwnerId', '$$userId'] } } },
|
|
128
|
+
{ $project: { '_id': 1, 'bookTitle': 1 }}, // <-- optional line to make responses smaller.
|
|
132
129
|
}]
|
|
133
130
|
}]
|
|
134
131
|
})
|
package/docs/readme.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/monastery)
|
|
3
|
+
[](https://www.npmjs.com/package/monastery)
|
|
4
|
+
<!--[](https://app.travis-ci.com/github/boycce/monastery)-->
|
|
4
5
|
|
|
5
6
|
> v3.0 has been released 🎉 refer to [breaking changes](#v3-breaking-changes) below when upgrading from v2.x.
|
|
6
7
|
|
|
@@ -137,6 +138,7 @@ You can view MongoDB's [compatibility table here](https://www.mongodb.com/docs/d
|
|
|
137
138
|
- Add soft remove plugin
|
|
138
139
|
- ~~Added deep path validation support for updates~~
|
|
139
140
|
- ~~Added option skipHooks~~
|
|
141
|
+
- beforeValidate should pass the document rather than the whole array of documents
|
|
140
142
|
|
|
141
143
|
## Debugging
|
|
142
144
|
|
package/lib/manager.js
CHANGED
|
@@ -66,11 +66,15 @@ function Manager(uri, opts, parent) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// Create a new MongoDB Client
|
|
69
|
-
if (
|
|
69
|
+
if (!that.uri) {
|
|
70
|
+
throw new Error('No monastery connection URI provided.')
|
|
71
|
+
} else if (typeof that.uri == 'string' || Array.isArray(that.uri)) {
|
|
70
72
|
that.uri = that.connectionString(that.uri, opts.databaseName)
|
|
71
73
|
that.client = new MongoClient(that.uri, mongoOpts)
|
|
72
|
-
} else {
|
|
74
|
+
} else if (util.isObject(that.uri)) {
|
|
73
75
|
that.client = that.uri
|
|
76
|
+
} else {
|
|
77
|
+
throw new Error('Invalid monastery connection URI provided.')
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
// Listen to MongoDB events
|
|
@@ -96,7 +100,8 @@ function Manager(uri, opts, parent) {
|
|
|
96
100
|
// Update the parent manager with the new manager
|
|
97
101
|
if (!hasDefaultManager && parent) hasDefaultManager = true
|
|
98
102
|
if (opts.promise) return that.open()
|
|
99
|
-
|
|
103
|
+
that.open()
|
|
104
|
+
return that // return that since it may be a different context
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
Manager.prototype.manager = function(uri, opts) {
|
|
@@ -130,7 +135,7 @@ Manager.prototype.close = async function() {
|
|
|
130
135
|
}
|
|
131
136
|
}
|
|
132
137
|
|
|
133
|
-
Manager.prototype.
|
|
138
|
+
Manager.prototype.rawCommand = function(...args) {
|
|
134
139
|
/**
|
|
135
140
|
* Run a raw MongoDB command
|
|
136
141
|
*/
|
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.5.
|
|
5
|
+
"version": "3.5.7",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "github:boycce/monastery",
|
|
8
8
|
"homepage": "https://boycce.github.io/monastery/",
|
package/test/collection.js
CHANGED
|
@@ -425,8 +425,8 @@ test('bulkWrite', async () => {
|
|
|
425
425
|
})
|
|
426
426
|
|
|
427
427
|
test('drop > should not throw when dropping an empty db', async () => {
|
|
428
|
-
|
|
429
|
-
expect(result).
|
|
428
|
+
await db.get('dropDB-' + Date.now()).drop().catch(() => false)
|
|
429
|
+
// expect(result).toBeUndefined()
|
|
430
430
|
})
|
|
431
431
|
|
|
432
432
|
test('caching collections', () => {
|
package/test/manager.js
CHANGED
|
@@ -8,12 +8,12 @@ test('manager > basics', async () => {
|
|
|
8
8
|
// Basic find command
|
|
9
9
|
expect(await db.db.collection('non-collection').findOne({})).toEqual(null)
|
|
10
10
|
// Raw MongoDB ping command
|
|
11
|
-
expect(await db.
|
|
11
|
+
expect(await db.rawCommand({ ping: 1 })).toMatchObject({ ok: 1 }) // cluster connections return extra fields
|
|
12
12
|
db.close()
|
|
13
13
|
})
|
|
14
14
|
|
|
15
15
|
test('manager > uri error', async () => {
|
|
16
|
-
expect(() => monastery.manager('', {})).toThrow('No connection URI provided.')
|
|
16
|
+
expect(() => monastery.manager('', {})).toThrow('No monastery connection URI provided.')
|
|
17
17
|
})
|
|
18
18
|
|
|
19
19
|
test('manager > onError', async () => {
|
|
@@ -21,7 +21,7 @@ test('manager > onError', async () => {
|
|
|
21
21
|
const db = monastery.manager('localhost:1234/monastery', { serverSelectionTimeoutMS: 500 })
|
|
22
22
|
let error, isAPromise
|
|
23
23
|
await db.onError((res) => { error = res.message }).then(() => { isAPromise = true })
|
|
24
|
-
expect(error).
|
|
24
|
+
expect(error).toContain('connect ECONNREFUSED 127.0.0.1:1234')
|
|
25
25
|
expect(isAPromise).toEqual(true)
|
|
26
26
|
db.close()
|
|
27
27
|
})
|
|
@@ -67,7 +67,7 @@ test('manager > return a promise', async () => {
|
|
|
67
67
|
|
|
68
68
|
test('manager > return a promise with uri error', async () => {
|
|
69
69
|
await expect(monastery.manager('badlocalhost/monastery', { serverSelectionTimeoutMS: 500, promise: true }))
|
|
70
|
-
.rejects.toThrow(
|
|
70
|
+
.rejects.toThrow(/getaddrinfo ENOTFOUND badlocalhost/)
|
|
71
71
|
})
|
|
72
72
|
|
|
73
73
|
test('manager > reuse MongoDB Client', async () => {
|