assai 0.0.2 → 0.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.
- package/index.mjs +1 -0
- package/package.json +3 -1
- package/src/collection.mjs +8 -1
- package/src/usecases/operation/index.mjs +1 -0
package/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "https://github.com/TimeLord2010/assai",
|
|
6
6
|
"type": "git"
|
|
7
7
|
},
|
|
8
8
|
"description": "A simple mongodb wrapper to make mongo even easier to work with.",
|
|
9
9
|
"main": "index.mjs",
|
|
10
|
+
"types": "dist/index.d.mts",
|
|
10
11
|
"scripts": {
|
|
12
|
+
"prepare": "tsc -p ./jsconfig.prod.json",
|
|
11
13
|
"start": "node --env-file=.env index.mjs",
|
|
12
14
|
"test": "node --env-file=.env --test"
|
|
13
15
|
},
|
package/src/collection.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { Collection } from 'mongodb'
|
|
|
2
2
|
import { getMongoClient } from './mongo_client.mjs'
|
|
3
3
|
import { deleteOneOrThrow } from './usecases/operation/additional/index.mjs'
|
|
4
4
|
import {
|
|
5
|
-
count, deleteMany, deleteOne, find, findOne, insertOne, updateMany, updateOne,
|
|
5
|
+
count, deleteMany, deleteOne, find, findOne, insertMany, insertOne, updateMany, updateOne,
|
|
6
6
|
} from './usecases/operation/index.mjs'
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -57,12 +57,14 @@ export async function getCollection(name, options = {}) {
|
|
|
57
57
|
* @template {import('./types.js').Projection<T>} K
|
|
58
58
|
* @param {import('mongodb').Filter<T>} query
|
|
59
59
|
* @param {import('./types.js').FindOptions<T, K>} options
|
|
60
|
+
* @returns {Promise<T[]>}
|
|
60
61
|
*/
|
|
61
62
|
find: async (query, options = {}) => await find({ query, options, getCollection }),
|
|
62
63
|
/**
|
|
63
64
|
* @template {import('./types.js').Projection<T> | undefined} K
|
|
64
65
|
* @param {import('mongodb').Filter<T>} query
|
|
65
66
|
* @param {import('./types.js').FindOptions<T,K>} options
|
|
67
|
+
* @returns {Promise<T | null>}
|
|
66
68
|
*/
|
|
67
69
|
findOne: async (query, options = {}) => {
|
|
68
70
|
return await findOne({ query, options, getCollection })
|
|
@@ -71,6 +73,11 @@ export async function getCollection(name, options = {}) {
|
|
|
71
73
|
* @param {import('./types.js').Optional<T, 'id'>} doc
|
|
72
74
|
*/
|
|
73
75
|
insertOne: async (doc) => await insertOne({ doc, getCollection }),
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
* @param {import('./types.js').Optional<T, 'id'>[]} docs
|
|
79
|
+
*/
|
|
80
|
+
insertMany: async (docs) => await insertMany({ docs, getCollection }),
|
|
74
81
|
/**
|
|
75
82
|
* @param {import('mongodb').Filter<T>} query
|
|
76
83
|
*/
|
|
@@ -4,6 +4,7 @@ export * from './delete_many.mjs'
|
|
|
4
4
|
export * from './delete_one.mjs'
|
|
5
5
|
export * from './find.mjs'
|
|
6
6
|
export * from './find_one.mjs'
|
|
7
|
+
export * from './insert_many.mjs'
|
|
7
8
|
export * from './insert_one.mjs'
|
|
8
9
|
export * from './update_many.mjs'
|
|
9
10
|
export * from './update_one.mjs'
|