notherbase-fs 4.5.6 → 4.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notherbase-fs",
3
- "version": "4.5.6",
3
+ "version": "4.5.7",
4
4
  "description": "Functions to help make developing for NotherBase easier.",
5
5
  "exports": "./notherbase-fs.js",
6
6
  "scripts": {
package/server/spirit.js CHANGED
@@ -44,6 +44,7 @@ let spiritSchema = new mongoose.Schema({
44
44
  spiritSchema.method("commit", async function(data = this.data, maxBackups = 5) {
45
45
  this._lastUpdate = Date.now();
46
46
 
47
+ if (!Array.isArray(this.backups)) this.backups = [];
47
48
  this.backups.unshift({
48
49
  _lastUpdate: Date.now(),
49
50
  data: this.data
@@ -65,6 +66,9 @@ spiritSchema.method("commit", async function(data = this.data, maxBackups = 5) {
65
66
  * @returns Status message.
66
67
  */
67
68
  spiritSchema.method("restoreBackup", async function(backupIndex) {
69
+ this._lastUpdate = Date.now();
70
+
71
+ if (!Array.isArray(this.backups)) this.backups = [];
68
72
  if (backupIndex < 0 || backupIndex >= this.backups.length) return "Invalid backup index";
69
73
  let backup = this.backups[backupIndex];
70
74
  this.backups.unshift({
package/server/user.js CHANGED
@@ -186,7 +186,6 @@ export default class User {
186
186
 
187
187
  spirit = new req.Spirit({
188
188
  service:"user",
189
- _lastUpdate: Date.now(),
190
189
  data: {
191
190
  username: req.body.username,
192
191
  password: hash,
@@ -198,10 +197,9 @@ export default class User {
198
197
  expires: 0
199
198
  },
200
199
  sessions: {}
201
- },
202
- backups: []
200
+ }
203
201
  });
204
- await spirit.save();
202
+ await spirit.commit();
205
203
 
206
204
  success(res, "Registration successful!");
207
205
  }
@@ -370,7 +368,7 @@ export default class User {
370
368
  parent: user._id,
371
369
  backups: data[i].backups || []
372
370
  });
373
- await spirit.save();
371
+ await spirit.commit();
374
372
  if (spirit) imported++;
375
373
  }
376
374
  }