inventory command handlers
This commit is contained in:
8 files changed
+715
-1441
No files matched your search
@@ -0,0 +1,35 @@
|
||||
const mongoose = require('mongoose');
|
||||
|
||||
let inventorySchema = mongoose.Schema({
|
||||
inventory: {
|
||||
userID: String,
|
||||
items: [],
|
||||
createdAt: Date,
|
||||
updatedAt: Date
|
||||
}
|
||||
});
|
||||
|
||||
inventorySchema.methods.createInventory = function (userID) {
|
||||
this.inventory.userID = userID;
|
||||
this.inventory.items = [];
|
||||
let walletData = {
|
||||
name: 'Wallet',
|
||||
type: 'wallet',
|
||||
description: '`/inventory wallet` to view wallet',
|
||||
cash: 0.00,
|
||||
ID: {
|
||||
firstname: '',
|
||||
lastname: '',
|
||||
dob: ''
|
||||
}
|
||||
}
|
||||
this.inventory.items.push(walletData);
|
||||
this.inventory.createdAt = new Date();
|
||||
this.inventory.updatedAt = this.inventory.createdAt;
|
||||
};
|
||||
|
||||
inventorySchema.methods.addItem = function (item) {
|
||||
this.inventory.items.push(item);
|
||||
};
|
||||
|
||||
module.exports = mongoose.model('Inventory', inventorySchema);
|
||||
Reference in new issue
Block a user