@tomsd/mongodbclient 2.3.0 → 2.4.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.
|
@@ -25,7 +25,7 @@ export declare class MClient {
|
|
|
25
25
|
connect(): Promise<MongoConnection>;
|
|
26
26
|
protected getConnected(): Promise<MongoConnection>;
|
|
27
27
|
upsert(pobj: any): Promise<unknown>;
|
|
28
|
-
read(condition
|
|
28
|
+
read(condition?: any, opt?: any): Promise<unknown>;
|
|
29
29
|
distinct(key: string, condition: any): Promise<unknown>;
|
|
30
30
|
remove(condition: any): Promise<unknown>;
|
|
31
31
|
stats(): Promise<unknown>;
|
|
@@ -25,7 +25,7 @@ export declare class MClient {
|
|
|
25
25
|
connect(): Promise<MongoConnection>;
|
|
26
26
|
protected getConnected(): Promise<MongoConnection>;
|
|
27
27
|
upsert(pobj: any): Promise<unknown>;
|
|
28
|
-
read(condition
|
|
28
|
+
read(condition?: any, opt?: any): Promise<unknown>;
|
|
29
29
|
distinct(key: string, condition: any): Promise<unknown>;
|
|
30
30
|
remove(condition: any): Promise<unknown>;
|
|
31
31
|
stats(): Promise<unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomsd/mongodbclient",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/cjs/mongodbclient.js",
|
|
6
6
|
"module": "dist/esm/mongodbclient.js",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"@types/mongodb": "^3.5.31",
|
|
25
25
|
"@types/node": "^14.14.5",
|
|
26
26
|
"@types/uuid": "^8.3.4",
|
|
27
|
+
"dotenv": "^16.0.1",
|
|
27
28
|
"mocha": "^7.0.1",
|
|
28
29
|
"ts-node": "^10.8.1",
|
|
29
30
|
"typescript": "^4.0.5"
|
package/test/test.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import dotenv from "dotenv";
|
|
3
|
+
dotenv.config();
|
|
4
|
+
|
|
1
5
|
import {describe, it } from "mocha";
|
|
2
6
|
import { MClient } from "../src/mongodbclient";
|
|
3
7
|
import { strict as assert } from "assert";
|
|
4
8
|
import { v4 as uuidv4 } from "uuid";
|
|
5
9
|
|
|
6
|
-
const mongouri =
|
|
10
|
+
const mongouri = process.env.MONGODB_URI as string;
|
|
7
11
|
const dbName = uuidv4();
|
|
8
12
|
const collName = uuidv4();
|
|
9
13
|
|
|
@@ -28,12 +32,12 @@ describe("MClient", () => {
|
|
|
28
32
|
});
|
|
29
33
|
|
|
30
34
|
it("read()", async () => {
|
|
31
|
-
const docs = (await mdbc.read(
|
|
35
|
+
const docs = (await mdbc.read()) as any[];
|
|
32
36
|
assert.equal(docs.length, items.length);
|
|
33
37
|
});
|
|
34
38
|
|
|
35
39
|
it("upsert()", async () => {
|
|
36
|
-
const docs = (await mdbc.read(
|
|
40
|
+
const docs = (await mdbc.read()) as any[];
|
|
37
41
|
const { modifiedCount } = (await mdbc.upsert({ _id: docs[0]._id, name: "david" })) as { modifiedCount: number };
|
|
38
42
|
assert.equal(modifiedCount, 1);
|
|
39
43
|
});
|