@minesa-org/mini-interaction 0.4.6 → 0.4.7
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.
|
@@ -44,6 +44,10 @@ export class MiniDatabase {
|
|
|
44
44
|
this.config = config;
|
|
45
45
|
this.schema = schema;
|
|
46
46
|
}
|
|
47
|
+
sanitiseStoredData(data) {
|
|
48
|
+
const { _id, createdAt, updatedAt, ...rest } = data;
|
|
49
|
+
return rest;
|
|
50
|
+
}
|
|
47
51
|
/**
|
|
48
52
|
* Initializes the database connection.
|
|
49
53
|
*/
|
|
@@ -125,9 +129,10 @@ export class MiniDatabase {
|
|
|
125
129
|
const dataWithDefaults = this.schema
|
|
126
130
|
? this.schema.applyDefaults(data)
|
|
127
131
|
: data;
|
|
132
|
+
const sanitizedData = this.sanitiseStoredData(dataWithDefaults);
|
|
128
133
|
await collection.updateOne({ _id: key }, {
|
|
129
134
|
$set: {
|
|
130
|
-
...
|
|
135
|
+
...sanitizedData,
|
|
131
136
|
_id: key,
|
|
132
137
|
updatedAt: new Date(),
|
|
133
138
|
},
|
|
@@ -164,9 +169,10 @@ export class MiniDatabase {
|
|
|
164
169
|
const dataWithDefaults = this.schema
|
|
165
170
|
? this.schema.applyDefaults(merged)
|
|
166
171
|
: merged;
|
|
172
|
+
const sanitizedData = this.sanitiseStoredData(dataWithDefaults);
|
|
167
173
|
await collection.updateOne({ _id: key }, {
|
|
168
174
|
$set: {
|
|
169
|
-
...
|
|
175
|
+
...sanitizedData,
|
|
170
176
|
updatedAt: new Date(),
|
|
171
177
|
},
|
|
172
178
|
$setOnInsert: {
|
package/package.json
CHANGED