Guest User

Untitled

a guest
Aug 21st, 2023
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. const { Schema, model } = require('mongoose');
  2.  
  3. const itemSchema = new Schema({
  4. name: {
  5. type: String,
  6. required: true,
  7. },
  8. description: { type: String, required: true },
  9. });
  10.  
  11. const Item = model('Item', itemSchema);
  12.  
  13. module.exports = Item;
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. const { Schema } = require('mongoose');
  27. // eslint-disable-next-line no-unused-vars
  28. const Item = require('./item-schema');
  29.  
  30.  
  31. const inventoryItemSchema = new Schema({
  32. item: { type: Schema.Types.ObjectId, ref: 'Item', required: true },
  33. quantity: { type: Number, default: 0 },
  34. });
  35.  
  36. module.exports = inventoryItemSchema;
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. const { Schema, model } = require('mongoose');
  48. const inventoryItemSchema = require('./inventoryItemSchema');
  49.  
  50.  
  51. const inventorySchema = new Schema({
  52. player: { type: String, ref: 'structureSchema', required: true },
  53. items: [inventoryItemSchema],
  54. });
  55.  
  56. const Inventory = model('Inventory', inventorySchema);
  57.  
  58. module.exports = Inventory;
Advertisement
Add Comment
Please, Sign In to add comment