@tomsd/mongodbclient 3.0.9 → 3.0.11

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": "@tomsd/mongodbclient",
3
- "version": "3.0.9",
3
+ "version": "3.0.11",
4
4
  "description": "It's a handy mongodb client for easy-use.",
5
5
  "main": "dist/cjs/mongodbclient.js",
6
6
  "module": "dist/esm/mongodbclient.js",
@@ -15,8 +15,8 @@
15
15
  "lint:test": "eslint test/**/*.ts",
16
16
  "prepare": "husky install",
17
17
  "serve:doc": "mdbook --serve --directory docs",
18
- "test": "exit 0",
19
- "test_with_dburi": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha -r ts-node/register \"test/test.ts\" --timeout 30000"
18
+ "test": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha -r ts-node/register \"test/mclient.test.ts\" --timeout 30000",
19
+ "test_with_dburi": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha -r ts-node/register \"test/with_dburi.test.ts\" --timeout 30000"
20
20
  },
21
21
  "lint-staged": {
22
22
  "docs/**/*.html": [
@@ -48,6 +48,7 @@
48
48
  "@tomsd/md-book": "^0.16.0",
49
49
  "@types/mocha": "^9.1.1",
50
50
  "@types/node": "^14.14.5",
51
+ "@types/sinon": "^10.0.13",
51
52
  "@types/uuid": "^8.3.4",
52
53
  "@typescript-eslint/eslint-plugin": "^5.38.0",
53
54
  "dotenv": "^16.0.1",
@@ -61,6 +62,7 @@
61
62
  "lint-staged": "^13.0.3",
62
63
  "mocha": "^7.0.1",
63
64
  "prettier": "^2.7.1",
65
+ "sinon": "^14.0.0",
64
66
  "ts-node": "^10.8.1",
65
67
  "typescript": "^4.8.3"
66
68
  }
package/.env.default DELETED
@@ -1 +0,0 @@
1
- MONGODB_URI=mongodb+srv://...
package/.eslintrc.js DELETED
@@ -1,19 +0,0 @@
1
- module.exports = {
2
- env: {
3
- es2021: true,
4
- node: true
5
- },
6
- extends: [
7
- 'standard-with-typescript',
8
- 'prettier'
9
- ],
10
- overrides: [
11
- ],
12
- parserOptions: {
13
- ecmaVersion: 'latest',
14
- sourceType: 'module',
15
- project: './tsconfig.base.json'
16
- },
17
- rules: {
18
- }
19
- }
@@ -1,26 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- pull_request:
8
-
9
- jobs:
10
- build:
11
-
12
- runs-on: ubuntu-latest
13
-
14
- steps:
15
- - uses: actions/checkout@v2
16
-
17
- - name: Use Node.js
18
- uses: actions/setup-node@v1
19
- with:
20
- node-version: '16.x'
21
-
22
- - name: npm ci and build and test
23
- run: |
24
- npm install
25
- npm run build
26
- npm test
package/.husky/pre-commit DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname -- "$0")/_/husky.sh"
3
-
4
- npx lint-staged
package/test/test.ts DELETED
@@ -1,74 +0,0 @@
1
- import { describe, it } from "mocha";
2
- import { MClient } from "../src/mongodbclient";
3
- import { strict as assert } from "assert";
4
- import { v4 as uuidv4 } from "uuid";
5
- import dotenv from "dotenv";
6
- dotenv.config();
7
-
8
- const mongouri = process.env.MONGODB_URI as string;
9
- const dbName = uuidv4();
10
- const collName = uuidv4();
11
-
12
- const mdbc = new MClient(mongouri, dbName, collName);
13
-
14
- const items = [
15
- { name: "alice" },
16
- { name: "bob" },
17
- { name: "charlie" },
18
- { name: "alice" },
19
- ];
20
-
21
- describe("MClient", () => {
22
- it("insertMany()", async () => {
23
- const { insertedCount } = await mdbc.insertMany(items);
24
- assert.equal(insertedCount, items.length);
25
- });
26
-
27
- it("getCollections()", async () => {
28
- const collections = await mdbc.getCollections();
29
- assert(collections.length > 0);
30
- });
31
-
32
- it("read()", async () => {
33
- const docs = await mdbc.read();
34
- const getNames = (items: any[]): string =>
35
- Array.from(new Set(items.map(({ name }) => name)))
36
- .sort((a, b) => (a > b ? 1 : -1))
37
- .join("\n");
38
- assert.equal(getNames(docs), getNames(docs));
39
- });
40
-
41
- it("upsert()", async () => {
42
- const docs = await mdbc.read();
43
- const { modifiedCount } = await mdbc.upsert({
44
- _id: docs[0]._id,
45
- name: "david",
46
- });
47
- assert.equal(modifiedCount, 1);
48
- });
49
-
50
- it("distinct()", async () => {
51
- const names = await mdbc.distinct("name");
52
- assert.equal(names.length, 4);
53
- });
54
-
55
- it("dbStats()", async () => {
56
- const { storageSize } = await mdbc.dbStats();
57
- assert(storageSize > 0);
58
- });
59
-
60
- it("stats()", async () => {
61
- const { storageSize } = await mdbc.stats();
62
- assert(storageSize > 0);
63
- });
64
-
65
- it("count()", async () => {
66
- const n = await mdbc.count({ name: "alice" });
67
- assert.equal(n, 1);
68
- });
69
-
70
- it("remove()", async () => {
71
- const { deletedCount } = await mdbc.remove({});
72
- assert.equal(deletedCount, items.length);
73
- });
74
- });