@wxn0brp/db 0.3.1 → 0.3.2
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/dist/action.js +7 -7
- package/package.json +1 -1
package/dist/action.js
CHANGED
|
@@ -67,7 +67,7 @@ class dbActionC {
|
|
|
67
67
|
* Add a new entry to the specified database.
|
|
68
68
|
*/
|
|
69
69
|
async add(collection, arg, id_gen = true) {
|
|
70
|
-
this.checkCollection(collection);
|
|
70
|
+
await this.checkCollection(collection);
|
|
71
71
|
const cpath = this._getCollectionPath(collection);
|
|
72
72
|
const file = cpath + await getLastFile(cpath, this.options.maxFileSize);
|
|
73
73
|
if (id_gen)
|
|
@@ -81,7 +81,7 @@ class dbActionC {
|
|
|
81
81
|
async find(collection, arg, context = {}, options = {}, findOpts = {}) {
|
|
82
82
|
options.reverse = options.reverse || false;
|
|
83
83
|
options.max = options.max || -1;
|
|
84
|
-
this.checkCollection(collection);
|
|
84
|
+
await this.checkCollection(collection);
|
|
85
85
|
const cpath = this._getCollectionPath(collection);
|
|
86
86
|
const files = await getSortedFiles(cpath);
|
|
87
87
|
if (options.reverse)
|
|
@@ -112,7 +112,7 @@ class dbActionC {
|
|
|
112
112
|
* Find the first matching entry in the specified database based on search criteria.
|
|
113
113
|
*/
|
|
114
114
|
async findOne(collection, arg, context = {}, findOpts = {}) {
|
|
115
|
-
this.checkCollection(collection);
|
|
115
|
+
await this.checkCollection(collection);
|
|
116
116
|
const cpath = this._getCollectionPath(collection);
|
|
117
117
|
const files = await getSortedFiles(cpath);
|
|
118
118
|
for (let f of files) {
|
|
@@ -126,28 +126,28 @@ class dbActionC {
|
|
|
126
126
|
* Update entries in the specified database based on search criteria and an updater function or object.
|
|
127
127
|
*/
|
|
128
128
|
async update(collection, arg, updater, context = {}) {
|
|
129
|
-
this.checkCollection(collection);
|
|
129
|
+
await this.checkCollection(collection);
|
|
130
130
|
return await operationUpdater(this._getCollectionPath(collection), this.fileCpu.update.bind(this.fileCpu), false, arg, updater, context);
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
* Update the first matching entry in the specified database based on search criteria and an updater function or object.
|
|
134
134
|
*/
|
|
135
135
|
async updateOne(collection, arg, updater, context = {}) {
|
|
136
|
-
this.checkCollection(collection);
|
|
136
|
+
await this.checkCollection(collection);
|
|
137
137
|
return await operationUpdater(this._getCollectionPath(collection), this.fileCpu.update.bind(this.fileCpu), true, arg, updater, context);
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
* Remove entries from the specified database based on search criteria.
|
|
141
141
|
*/
|
|
142
142
|
async remove(collection, arg, context = {}) {
|
|
143
|
-
this.checkCollection(collection);
|
|
143
|
+
await this.checkCollection(collection);
|
|
144
144
|
return await operationUpdater(this._getCollectionPath(collection), this.fileCpu.remove.bind(this.fileCpu), false, arg, context);
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
147
147
|
* Remove the first matching entry from the specified database based on search criteria.
|
|
148
148
|
*/
|
|
149
149
|
async removeOne(collection, arg, context = {}) {
|
|
150
|
-
this.checkCollection(collection);
|
|
150
|
+
await this.checkCollection(collection);
|
|
151
151
|
return await operationUpdater(this._getCollectionPath(collection), this.fileCpu.remove.bind(this.fileCpu), true, arg, context);
|
|
152
152
|
}
|
|
153
153
|
/**
|
package/package.json
CHANGED