Click here to Skip to main content
15,887,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
so i am trying to select a specific array from my department-> dStock collection.
i want to select it like i would any other data fields in my initial collection and edit or delete it or simply check for duplicates before adding info.

What I have tried:

let departmentStock = await Department.findOne({
 departmentName,
 departmentProperty,
 dStock: { itemCode, itemName }, 


i am not sure about the last line above, here i want to filter by department stock(dStock) then edit this information and reinsert it or simply update it });

as shown below dStock is an array of items withing the department Module.

const DepartmentSchema = new mongoose.Schema(
  {
    departmentName: { type: String, required: true, trim: true, minlength: 3 },
    dStock: [
      {
        itemCode: { type: String, required: true, trim: true, minlength: 3 },
        itemName: { type: String, required: true, trim: true, minlength: 3 },
        itemQty: { type: Number, trim: true },
      },
    ],
    dOpenTime: { type: Date, trim: true, minlength: 4 },
Posted
Updated 5-Jul-20 5:48am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900