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 CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014-2021 Linus Unnebäck
3
+ Copyright (c) 2014-2025 Linus Unnebäck
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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.Filter<TSchema>, options?: WithoutProjection<mongodb.FindOptions<TSchema>>): Promise<TSchema | null>
24
- findOne<TKey extends keyof TSchema> (filter: mongodb.Filter<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.Filter<TSchema>, options: SpecificProjection<mongodb.FindOptions<TSchema>, { [key in TKey]: 1 | true } & { _id?: 1 | true }>): Promise<Pick<TSchema, '_id' | TKey> | null>
26
- findOne (filter: mongodb.Filter<TSchema>, options: mongodb.FindOptions<TSchema>): Promise<object | null>
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.Filter<TSchema>, options?: WithoutProjection<mongodb.FindOptions<TSchema>>): Promise<TSchema[]>
29
- find<TKey extends keyof TSchema> (query: mongodb.Filter<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.Filter<TSchema>, options: SpecificProjection<mongodb.FindOptions<TSchema>, { [key in TKey]: 1 | true } & { _id?: 1 | true }>): Promise<Array<Pick<TSchema, '_id' | TKey>>>
31
- find (query: mongodb.Filter<TSchema>, options: mongodb.FindOptions<TSchema>): Promise<object[]>
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.Filter<TSchema>, options?: mongodb.CountOptions): Promise<number>
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.Filter<TSchema>, options?: mongodb.DistinctOptions): Promise<Array<mongodb.Flatten<mongodb.WithId<TSchema>[TKey]>>>
36
- distinct (key: string, query?: mongodb.Filter<TSchema>, options?: mongodb.DistinctOptions): Promise<any[]>
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.Filter<TSchema>, options?: { hint?: mongodb.Hint }): Promise<boolean>
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.Filter<TSchema>, update: mongodb.UpdateFilter<TSchema>, options: WithoutProjection<FindOneAndUpdateOptions & { returnDocument: 'after', upsert: true }>): Promise<TSchema>
44
- findOneAndUpdate (filter: mongodb.Filter<TSchema>, update: mongodb.UpdateFilter<TSchema>, options?: WithoutProjection<FindOneAndUpdateOptions>): Promise<TSchema | null>
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.Filter<TSchema>, update: mongodb.UpdateFilter<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.Filter<TSchema>, update: mongodb.UpdateFilter<TSchema>, options: SpecificProjection<FindOneAndUpdateOptions, { [key in TKey]: 1 | true } & { _id: 0 | false }>): Promise<Pick<TSchema, TKey> | null>
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.Filter<TSchema>, update: mongodb.UpdateFilter<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.Filter<TSchema>, update: mongodb.UpdateFilter<TSchema>, options: SpecificProjection<FindOneAndUpdateOptions, { [key in TKey]: 1 | true } & { _id?: 1 | true }>): Promise<Pick<TSchema, '_id' | TKey> | null>
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.Filter<TSchema>, update: mongodb.UpdateFilter<TSchema>, options: FindOneAndUpdateOptions & { returnDocument: 'after', upsert: true }): Promise<object>
53
- findOneAndUpdate (filter: mongodb.Filter<TSchema>, update: mongodb.UpdateFilter<TSchema>, options?: FindOneAndUpdateOptions): Promise<object | null>
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.Filter<TSchema>, update: mongodb.UpdateFilter<TSchema> | Partial<TSchema>, options?: mongodb.UpdateOptions): Promise<{ matched: 0 | 1, modified: 0 | 1 }>
56
- updateMany (filter: mongodb.Filter<TSchema>, update: mongodb.UpdateFilter<TSchema>, options?: mongodb.UpdateOptions): Promise<{ matched: number, modified: number }>
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.Filter<TSchema>, options?: mongodb.DeleteOptions): Promise<0 | 1>
59
- deleteMany (filter: mongodb.Filter<TSchema>, options?: mongodb.DeleteOptions): Promise<number>
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((resolve, reject) => {
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 BSON from 'bson'
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 BSON.deserialize(BSON.serialize(document), { promoteValues: true })
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
- return new Promise((resolve, reject) => {
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": "4.0.0",
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": "^4.7.0",
19
- "debug": "^4.3.4",
20
- "mongodb": "^4.9.0"
18
+ "bson": "^5.5.1",
19
+ "debug": "^4.4.1",
20
+ "mongodb": "^5.9.2"
21
21
  },
22
22
  "devDependencies": {
23
- "@types/mocha": "^9.0.0",
23
+ "@types/mocha": "^10.0.10",
24
24
  "@types/node": "^16.4.13",
25
25
  "get-stream": "^6.0.1",
26
- "mocha": "^9.0.3",
26
+ "mocha": "^10.8.2",
27
27
  "standard": "^17.0.0",
28
- "typescript": "^4.8.2"
28
+ "typescript": "^5.8.3"
29
29
  },
30
30
  "engines": {
31
- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
31
+ "node": "^14.20.1 || >=16.0.0"
32
32
  }
33
33
  }