@tomsd/mongodbclient 2.2.2 → 2.3.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.
|
@@ -9,7 +9,7 @@ exports.MClient = exports.MongoConnection = void 0;
|
|
|
9
9
|
const MongoClient = require("mongodb").MongoClient;
|
|
10
10
|
const Db = require("mongodb").Db;
|
|
11
11
|
const { Collection, UpdateWriteOpResult, deleteWriteOpResult, insertWriteOpResult } = require("mongodb");
|
|
12
|
-
const
|
|
12
|
+
const uuid_1 = require("uuid");
|
|
13
13
|
class MongoConnection {
|
|
14
14
|
constructor(client, db, collection) {
|
|
15
15
|
this._client = client;
|
|
@@ -62,7 +62,7 @@ class MClient {
|
|
|
62
62
|
}
|
|
63
63
|
upsert(pobj) {
|
|
64
64
|
const that = this;
|
|
65
|
-
pobj._id = "_id" in pobj ? pobj._id :
|
|
65
|
+
pobj._id = "_id" in pobj ? pobj._id : uuid_1.v4();
|
|
66
66
|
return new Promise(function (resolve, reject) {
|
|
67
67
|
that.getConnected()
|
|
68
68
|
.then(function (conn) {
|
|
@@ -167,7 +167,7 @@ class MClient {
|
|
|
167
167
|
insertMany(items) {
|
|
168
168
|
const that = this;
|
|
169
169
|
items.forEach(function (item) {
|
|
170
|
-
item._id = item._id ? item._id :
|
|
170
|
+
item._id = item._id ? item._id : uuid_1.v4();
|
|
171
171
|
});
|
|
172
172
|
return new Promise(function (resolve, reject) {
|
|
173
173
|
that.getConnected()
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
const MongoClient = require("mongodb").MongoClient;
|
|
7
7
|
const Db = require("mongodb").Db;
|
|
8
8
|
const { Collection, UpdateWriteOpResult, deleteWriteOpResult, insertWriteOpResult } = require("mongodb");
|
|
9
|
-
|
|
9
|
+
import { v4 as uuidv4 } from "uuid";
|
|
10
10
|
export class MongoConnection {
|
|
11
11
|
constructor(client, db, collection) {
|
|
12
12
|
this._client = client;
|
|
@@ -58,7 +58,7 @@ export class MClient {
|
|
|
58
58
|
}
|
|
59
59
|
upsert(pobj) {
|
|
60
60
|
const that = this;
|
|
61
|
-
pobj._id = "_id" in pobj ? pobj._id :
|
|
61
|
+
pobj._id = "_id" in pobj ? pobj._id : uuidv4();
|
|
62
62
|
return new Promise(function (resolve, reject) {
|
|
63
63
|
that.getConnected()
|
|
64
64
|
.then(function (conn) {
|
|
@@ -163,7 +163,7 @@ export class MClient {
|
|
|
163
163
|
insertMany(items) {
|
|
164
164
|
const that = this;
|
|
165
165
|
items.forEach(function (item) {
|
|
166
|
-
item._id = item._id ? item._id :
|
|
166
|
+
item._id = item._id ? item._id : uuidv4();
|
|
167
167
|
});
|
|
168
168
|
return new Promise(function (resolve, reject) {
|
|
169
169
|
that.getConnected()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomsd/mongodbclient",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/cjs/mongodbclient.js",
|
|
6
6
|
"module": "dist/esm/mongodbclient.js",
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"author": "tom",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@tomsd/rand": "^3.0.0",
|
|
20
19
|
"mongodb": "^3.6.6",
|
|
21
20
|
"uuid": "^8.3.2"
|
|
22
21
|
},
|