@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.
@@ -35,6 +35,7 @@ export declare class MiniDatabase {
35
35
  collectionName?: string;
36
36
  }): MiniDatabase;
37
37
  constructor(config: DatabaseConfig, schema?: MiniDataBuilder);
38
+ private sanitiseStoredData;
38
39
  /**
39
40
  * Initializes the database connection.
40
41
  */
@@ -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
- ...dataWithDefaults,
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
- ...dataWithDefaults,
175
+ ...sanitizedData,
170
176
  updatedAt: new Date(),
171
177
  },
172
178
  $setOnInsert: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minesa-org/mini-interaction",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "Mini interaction, connecting your app with Discord via HTTP-interaction (Vercel support).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",