albatross 4.0.0 → 5.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/LICENSE +1 -1
- package/index.d.ts +24 -24
- package/lib/albatross.js +1 -1
- package/lib/collection.js +2 -2
- package/lib/grid.js +2 -5
- package/package.json +8 -8
package/LICENSE
CHANGED
package/index.d.ts
CHANGED
|
@@ -20,43 +20,43 @@ export interface Collection<TSchema extends { _id: any }> {
|
|
|
20
20
|
readonly parent: Albatross
|
|
21
21
|
id (hexString?: mongodb.ObjectId | string): mongodb.ObjectId
|
|
22
22
|
|
|
23
|
-
findOne (filter: mongodb.
|
|
24
|
-
findOne<TKey extends keyof TSchema> (filter: mongodb.
|
|
25
|
-
findOne<TKey extends keyof TSchema> (filter: mongodb.
|
|
26
|
-
findOne (filter: mongodb.
|
|
23
|
+
findOne (filter: mongodb.StrictFilter<TSchema>, options?: WithoutProjection<mongodb.FindOptions<TSchema>>): Promise<TSchema | null>
|
|
24
|
+
findOne<TKey extends keyof TSchema> (filter: mongodb.StrictFilter<TSchema>, options: SpecificProjection<mongodb.FindOptions<TSchema>, { [key in TKey]: 1 | true } & { _id: 0 | false }>): Promise<Pick<TSchema, TKey> | null>
|
|
25
|
+
findOne<TKey extends keyof TSchema> (filter: mongodb.StrictFilter<TSchema>, options: SpecificProjection<mongodb.FindOptions<TSchema>, { [key in TKey]: 1 | true } & { _id?: 1 | true }>): Promise<Pick<TSchema, '_id' | TKey> | null>
|
|
26
|
+
findOne (filter: mongodb.StrictFilter<TSchema>, options: mongodb.FindOptions<TSchema>): Promise<object | null>
|
|
27
27
|
|
|
28
|
-
find (query: mongodb.
|
|
29
|
-
find<TKey extends keyof TSchema> (query: mongodb.
|
|
30
|
-
find<TKey extends keyof TSchema> (query: mongodb.
|
|
31
|
-
find (query: mongodb.
|
|
28
|
+
find (query: mongodb.StrictFilter<TSchema>, options?: WithoutProjection<mongodb.FindOptions<TSchema>>): Promise<TSchema[]>
|
|
29
|
+
find<TKey extends keyof TSchema> (query: mongodb.StrictFilter<TSchema>, options: SpecificProjection<mongodb.FindOptions<TSchema>, { [key in TKey]: 1 | true } & { _id: 0 | false }>): Promise<Array<Pick<TSchema, TKey>>>
|
|
30
|
+
find<TKey extends keyof TSchema> (query: mongodb.StrictFilter<TSchema>, options: SpecificProjection<mongodb.FindOptions<TSchema>, { [key in TKey]: 1 | true } & { _id?: 1 | true }>): Promise<Array<Pick<TSchema, '_id' | TKey>>>
|
|
31
|
+
find (query: mongodb.StrictFilter<TSchema>, options: mongodb.FindOptions<TSchema>): Promise<object[]>
|
|
32
32
|
|
|
33
|
-
count (query?: mongodb.
|
|
33
|
+
count (query?: mongodb.StrictFilter<TSchema>, options?: mongodb.CountOptions): Promise<number>
|
|
34
34
|
|
|
35
|
-
distinct<TKey extends keyof mongodb.WithId<TSchema>> (key: TKey, query?: mongodb.
|
|
36
|
-
distinct (key: string, query?: mongodb.
|
|
35
|
+
distinct<TKey extends keyof mongodb.WithId<TSchema>> (key: TKey, query?: mongodb.StrictFilter<TSchema>, options?: mongodb.DistinctOptions): Promise<Array<mongodb.Flatten<mongodb.WithId<TSchema>[TKey]>>>
|
|
36
|
+
distinct (key: string, query?: mongodb.StrictFilter<TSchema>, options?: mongodb.DistinctOptions): Promise<any[]>
|
|
37
37
|
|
|
38
|
-
exists (query?: mongodb.
|
|
38
|
+
exists (query?: mongodb.StrictFilter<TSchema>, options?: { hint?: mongodb.Hint }): Promise<boolean>
|
|
39
39
|
|
|
40
40
|
insert (doc: DeepReadonly<mongodb.OptionalId<TSchema>>, options?: mongodb.InsertOneOptions): Promise<mongodb.WithId<TSchema>>
|
|
41
41
|
insert (docs: DeepReadonly<mongodb.OptionalId<TSchema>>[], options?: mongodb.BulkWriteOptions): Promise<mongodb.WithId<TSchema>[]>
|
|
42
42
|
|
|
43
|
-
findOneAndUpdate (filter: mongodb.
|
|
44
|
-
findOneAndUpdate (filter: mongodb.
|
|
43
|
+
findOneAndUpdate (filter: mongodb.StrictFilter<TSchema>, update: mongodb.StrictUpdateFilter<TSchema>, options: WithoutProjection<FindOneAndUpdateOptions & { returnDocument: 'after', upsert: true }>): Promise<TSchema>
|
|
44
|
+
findOneAndUpdate (filter: mongodb.StrictFilter<TSchema>, update: mongodb.StrictUpdateFilter<TSchema>, options?: WithoutProjection<FindOneAndUpdateOptions>): Promise<TSchema | null>
|
|
45
45
|
|
|
46
|
-
findOneAndUpdate<TKey extends keyof TSchema> (filter: mongodb.
|
|
47
|
-
findOneAndUpdate<TKey extends keyof TSchema> (filter: mongodb.
|
|
46
|
+
findOneAndUpdate<TKey extends keyof TSchema> (filter: mongodb.StrictFilter<TSchema>, update: mongodb.StrictUpdateFilter<TSchema>, options: SpecificProjection<FindOneAndUpdateOptions & { returnDocument: 'after', upsert: true }, { [key in TKey]: 1 | true } & { _id: 0 | false }>): Promise<Pick<TSchema, TKey>>
|
|
47
|
+
findOneAndUpdate<TKey extends keyof TSchema> (filter: mongodb.StrictFilter<TSchema>, update: mongodb.StrictUpdateFilter<TSchema>, options: SpecificProjection<FindOneAndUpdateOptions, { [key in TKey]: 1 | true } & { _id: 0 | false }>): Promise<Pick<TSchema, TKey> | null>
|
|
48
48
|
|
|
49
|
-
findOneAndUpdate<TKey extends keyof TSchema> (filter: mongodb.
|
|
50
|
-
findOneAndUpdate<TKey extends keyof TSchema> (filter: mongodb.
|
|
49
|
+
findOneAndUpdate<TKey extends keyof TSchema> (filter: mongodb.StrictFilter<TSchema>, update: mongodb.StrictUpdateFilter<TSchema>, options: SpecificProjection<FindOneAndUpdateOptions & { returnDocument: 'after', upsert: true }, { [key in TKey]: 1 | true } & { _id?: 1 | true }>): Promise<Pick<TSchema, '_id' | TKey>>
|
|
50
|
+
findOneAndUpdate<TKey extends keyof TSchema> (filter: mongodb.StrictFilter<TSchema>, update: mongodb.StrictUpdateFilter<TSchema>, options: SpecificProjection<FindOneAndUpdateOptions, { [key in TKey]: 1 | true } & { _id?: 1 | true }>): Promise<Pick<TSchema, '_id' | TKey> | null>
|
|
51
51
|
|
|
52
|
-
findOneAndUpdate (filter: mongodb.
|
|
53
|
-
findOneAndUpdate (filter: mongodb.
|
|
52
|
+
findOneAndUpdate (filter: mongodb.StrictFilter<TSchema>, update: mongodb.StrictUpdateFilter<TSchema>, options: FindOneAndUpdateOptions & { returnDocument: 'after', upsert: true }): Promise<object>
|
|
53
|
+
findOneAndUpdate (filter: mongodb.StrictFilter<TSchema>, update: mongodb.StrictUpdateFilter<TSchema>, options?: FindOneAndUpdateOptions): Promise<object | null>
|
|
54
54
|
|
|
55
|
-
updateOne (filter: mongodb.
|
|
56
|
-
updateMany (filter: mongodb.
|
|
55
|
+
updateOne (filter: mongodb.StrictFilter<TSchema>, update: mongodb.StrictUpdateFilter<TSchema> | Partial<TSchema>, options?: mongodb.UpdateOptions): Promise<{ matched: 0 | 1, modified: 0 | 1 }>
|
|
56
|
+
updateMany (filter: mongodb.StrictFilter<TSchema>, update: mongodb.StrictUpdateFilter<TSchema>, options?: mongodb.UpdateOptions): Promise<{ matched: number, modified: number }>
|
|
57
57
|
|
|
58
|
-
deleteOne (filter: mongodb.
|
|
59
|
-
deleteMany (filter: mongodb.
|
|
58
|
+
deleteOne (filter: mongodb.StrictFilter<TSchema>, options?: mongodb.DeleteOptions): Promise<0 | 1>
|
|
59
|
+
deleteMany (filter: mongodb.StrictFilter<TSchema>, options?: mongodb.DeleteOptions): Promise<number>
|
|
60
60
|
|
|
61
61
|
aggregate (pipeline: object[], options?: mongodb.AggregateOptions): Promise<object[]>
|
|
62
62
|
|
package/lib/albatross.js
CHANGED
|
@@ -51,7 +51,7 @@ export default class Albatross {
|
|
|
51
51
|
|
|
52
52
|
try {
|
|
53
53
|
if (typeof timeout === 'number') {
|
|
54
|
-
const timeoutPromise = new Promise((
|
|
54
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
55
55
|
timeoutHandle = setTimeout(() => {
|
|
56
56
|
timeoutHandle = null
|
|
57
57
|
reject(new Error('Timeout reached while waiting for ping'))
|
package/lib/collection.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { deserialize, serialize } from 'bson'
|
|
2
2
|
import debug from 'debug'
|
|
3
3
|
|
|
4
4
|
const kDebug = Symbol('debug')
|
|
5
5
|
|
|
6
6
|
function prepareDocument (document) {
|
|
7
|
-
return
|
|
7
|
+
return deserialize(serialize(document), { promoteValues: true })
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export default class Collection {
|
package/lib/grid.js
CHANGED
|
@@ -70,10 +70,7 @@ export default class Grid {
|
|
|
70
70
|
|
|
71
71
|
async delete (id) {
|
|
72
72
|
const db = await this.parent.db()
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const bucket = new mongodb.GridFSBucket(db, { bucketName: this.name })
|
|
76
|
-
bucket.delete(this.id(id), (err) => err ? reject(err) : resolve())
|
|
77
|
-
})
|
|
73
|
+
const bucket = new mongodb.GridFSBucket(db, { bucketName: this.name })
|
|
74
|
+
await bucket.delete(this.id(id))
|
|
78
75
|
}
|
|
79
76
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "albatross",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "LinusU/node-albatross",
|
|
6
6
|
"type": "module",
|
|
@@ -15,19 +15,19 @@
|
|
|
15
15
|
"tsc": "tsc --allowSyntheticDefaultImports --noEmit --allowJs --checkJs index.d.ts test/*.js"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"bson": "^
|
|
19
|
-
"debug": "^4.
|
|
20
|
-
"mongodb": "^
|
|
18
|
+
"bson": "^5.5.1",
|
|
19
|
+
"debug": "^4.4.1",
|
|
20
|
+
"mongodb": "^5.9.2"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/mocha": "^
|
|
23
|
+
"@types/mocha": "^10.0.10",
|
|
24
24
|
"@types/node": "^16.4.13",
|
|
25
25
|
"get-stream": "^6.0.1",
|
|
26
|
-
"mocha": "^
|
|
26
|
+
"mocha": "^10.8.2",
|
|
27
27
|
"standard": "^17.0.0",
|
|
28
|
-
"typescript": "^
|
|
28
|
+
"typescript": "^5.8.3"
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
31
|
-
"node": "^
|
|
31
|
+
"node": "^14.20.1 || >=16.0.0"
|
|
32
32
|
}
|
|
33
33
|
}
|