assai 1.0.0 → 1.1.1

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.
@@ -64,13 +64,15 @@ export function createMongoCollection<T extends import("../types.js").MongoDocum
64
64
  /**
65
65
  * @param {import('mongodb').Filter<T>} query
66
66
  * @param {import('mongodb').UpdateFilter<T>} update
67
+ * @param {import('mongodb').UpdateOptions} [options]
67
68
  */
68
- updateOne: (query: import("mongodb").Filter<T>, update: import("mongodb").UpdateFilter<T>) => Promise<boolean>;
69
+ updateOne: (query: import("mongodb").Filter<T>, update: import("mongodb").UpdateFilter<T>, options?: import("mongodb").UpdateOptions | undefined) => Promise<boolean>;
69
70
  /**
70
71
  * @param {import('mongodb').Filter<T>} query
71
72
  * @param {import('mongodb').UpdateFilter<T>} update
73
+ * @param {import('mongodb').UpdateOptions} [options]
72
74
  */
73
- updateMany: (query: import("mongodb").Filter<T>, update: import("mongodb").UpdateFilter<T>) => Promise<import("mongodb").UpdateResult<T>>;
75
+ updateMany: (query: import("mongodb").Filter<T>, update: import("mongodb").UpdateFilter<T>, options?: import("mongodb").UpdateOptions | undefined) => Promise<import("mongodb").UpdateResult<T>>;
74
76
  };
75
77
  export type IcollectionGetter<T extends import("../types.js").MongoDocument> = () => Promise<Collection<T>>;
76
78
  export type IcreateCollectionOptions<T extends import("../types.js").MongoDocument> = {
@@ -3,11 +3,13 @@
3
3
  * @param {object} param
4
4
  * @param {import('mongodb').Filter<T>} param.query
5
5
  * @param {import('mongodb').UpdateFilter<T>} param.update
6
+ * @param {import('mongodb').UpdateOptions} [param.options]
6
7
  * @param {() => Promise<Collection<T>>} param.getCollection
7
8
  */
8
- export function updateMany<T extends import("../../../types.js").MongoDocument>({ query, update, getCollection }: {
9
+ export function updateMany<T extends import("../../../types.js").MongoDocument>({ query, update, options, getCollection }: {
9
10
  query: import("mongodb").Filter<T>;
10
11
  update: import("mongodb").UpdateFilter<T>;
12
+ options?: import("mongodb").UpdateOptions | undefined;
11
13
  getCollection: () => Promise<Collection<T>>;
12
14
  }): Promise<import("mongodb").UpdateResult<T>>;
13
15
  import { Collection } from 'mongodb';
@@ -3,11 +3,13 @@
3
3
  * @param {object} param
4
4
  * @param {import('mongodb').Filter<T>} param.query
5
5
  * @param {import('mongodb').UpdateFilter<T>} param.update
6
+ * @param {import('mongodb').UpdateOptions} [param.options]
6
7
  * @param {() => Promise<Collection<T>>} param.getCollection
7
8
  */
8
- export function updateOne<T extends import("../../../types.js").MongoDocument>({ query, update, getCollection }: {
9
+ export function updateOne<T extends import("../../../types.js").MongoDocument>({ query, update, options, getCollection }: {
9
10
  query: import("mongodb").Filter<T>;
10
11
  update: import("mongodb").UpdateFilter<T>;
12
+ options?: import("mongodb").UpdateOptions | undefined;
11
13
  getCollection: () => Promise<Collection<T>>;
12
14
  }): Promise<boolean>;
13
15
  import { Collection } from 'mongodb';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assai",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "repository": {
5
5
  "url": "https://github.com/TimeLord2010/assai",
6
6
  "type": "git"
@@ -141,13 +141,19 @@ export function createMongoCollection(name, options = {}) {
141
141
  /**
142
142
  * @param {import('mongodb').Filter<T>} query
143
143
  * @param {import('mongodb').UpdateFilter<T>} update
144
+ * @param {import('mongodb').UpdateOptions} [options]
144
145
  */
145
- updateOne: async (query, update) => await updateOne({ query, update, getCollection }),
146
+ updateOne: async (query, update, options) => await updateOne({
147
+ query, update, options, getCollection,
148
+ }),
146
149
  /**
147
150
  * @param {import('mongodb').Filter<T>} query
148
151
  * @param {import('mongodb').UpdateFilter<T>} update
152
+ * @param {import('mongodb').UpdateOptions} [options]
149
153
  */
150
- updateMany: async (query, update) => await updateMany({ query, update, getCollection })
154
+ updateMany: async (query, update, options) => await updateMany({
155
+ query, update, options, getCollection,
156
+ })
151
157
  }
152
158
  }
153
159
 
@@ -6,13 +6,14 @@ import { renameToMongoId, stringsIntoId } from '../transformers/index.mjs'
6
6
  * @param {object} param
7
7
  * @param {import('mongodb').Filter<T>} param.query
8
8
  * @param {import('mongodb').UpdateFilter<T>} param.update
9
+ * @param {import('mongodb').UpdateOptions} [param.options]
9
10
  * @param {() => Promise<Collection<T>>} param.getCollection
10
11
  */
11
- export async function updateMany({ query, update, getCollection }) {
12
+ export async function updateMany({ query, update, options, getCollection }) {
12
13
  query = renameToMongoId(query)
13
14
  stringsIntoId(query)
14
15
  stringsIntoId(update)
15
16
  const col = await getCollection()
16
- const r = await col.updateMany(query, update)
17
+ const r = await col.updateMany(query, update, options)
17
18
  return r
18
19
  }
@@ -6,13 +6,14 @@ import { renameToMongoId, stringsIntoId } from '../transformers/index.mjs'
6
6
  * @param {object} param
7
7
  * @param {import('mongodb').Filter<T>} param.query
8
8
  * @param {import('mongodb').UpdateFilter<T>} param.update
9
+ * @param {import('mongodb').UpdateOptions} [param.options]
9
10
  * @param {() => Promise<Collection<T>>} param.getCollection
10
11
  */
11
- export async function updateOne({ query, update, getCollection }) {
12
+ export async function updateOne({ query, update, options, getCollection }) {
12
13
  query = renameToMongoId(query)
13
14
  stringsIntoId(query)
14
15
  stringsIntoId(update)
15
16
  const col = await getCollection()
16
- const r = await col.updateOne(query, update)
17
+ const r = await col.updateOne(query, update, options)
17
18
  return r.matchedCount > 0
18
19
  }