assai 2.1.2 → 2.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assai",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "repository": {
5
5
  "url": "https://github.com/TimeLord2010/assai",
6
6
  "type": "git"
@@ -1,5 +1,6 @@
1
1
  import { Collection, ObjectId } from 'mongodb'
2
2
  import { inputTransformer } from '../transformers/input_transformer.mjs'
3
+ import { outputTransformer } from '../transformers/output_transformer.mjs'
3
4
 
4
5
  /**
5
6
  * @template {import('../../../types.js').MongoDocument} T
@@ -30,11 +31,16 @@ export async function insertMany({ docs, collectionOptions, getCollection }) {
30
31
  let { insertedIds } = result
31
32
  const indexes = Object.keys(insertedIds)
32
33
  for (const index of indexes) {
34
+ // @ts-ignore
33
35
  const id = insertedIds[index]
34
36
  if (id instanceof ObjectId) {
37
+ // @ts-ignore
35
38
  docs[index].id = id.toHexString()
36
39
  }
37
40
  }
38
- // @ts-ignore
39
- return docs
41
+ return docs.map(doc => outputTransformer({
42
+ // @ts-ignore
43
+ document: doc,
44
+ collectionOptions
45
+ }))
40
46
  }
@@ -1,5 +1,6 @@
1
1
  import { Collection, ObjectId } from 'mongodb'
2
2
  import { inputTransformer } from '../transformers/input_transformer.mjs'
3
+ import { outputTransformer } from '../transformers/output_transformer.mjs'
3
4
 
4
5
  /**
5
6
  * @template {import('../../../types.js').MongoDocument} T
@@ -26,8 +27,12 @@ export async function insertOne({ doc, collectionOptions, getCollection }) {
26
27
  id = id.toHexString()
27
28
  }
28
29
 
29
- delete doc._id
30
-
31
30
  // @ts-ignore
32
- return { id, ...doc }
31
+ doc.id = id
32
+
33
+ return outputTransformer({
34
+ // @ts-ignore
35
+ document: doc,
36
+ collectionOptions,
37
+ })
33
38
  }