Array of Object IDs when creating new array item

Feature(s) impacted

OneToMany, Schemas

Observed behavior

When trying to create a new object I am unable to link the item I am trying to add to my array, please see images attached as this is very vague, im not so sure how to describe the issue

Expected behavior

When it’s not an array it allows me to type the item and a dropdown will show me the items linked

Context

  • Environment name: Most Recent MongoDB NodeJs
  • Agent (forest package) name & version: 9
  • Database type: MongoDB
  • Recent changes made on your end if any: None

Dock.ts

const dockQueueItem = new Mongoose.Schema({
  **pickables: [{ type: Mongoose.Schema.Types.ObjectId, ref: "pickable" }]**,
  loaded: { type: Boolean, default: false },
  track: [String],
});

const dockSchema = new Mongoose.Schema(
  {
    identifier: { type: String, unique: true },
    queue: [{ type: dockQueueItem }],
    createdAt: { type: Date, default: Date.now },
  },
  {
    timestamps: false,
  },
);

The bolded part is the one I am having an issue with when adding a new Purchase order to my purchase orders array, it won’t show any available purchase order items, where as if I don’t make it an array it will show the dropdown to select

Hello @DannySaludSativa,

Thanks for your feedback.

Could you please also share the declaration of your models?

If I follow the documentation for MongoDB and forest-express-mongoose, it seems that this syntax is supported:

Here is an example from the docs:

module.exports = (mongoose, Mongoose) => {
  const schema = Mongoose.Schema({
    ...
    'orders': [{ type: Mongoose.Schema.Types.ObjectId, ref: 'orders' }],
    ...
  }, {
    timestamps: true,
  });

  return mongoose.model('customers', schema, 'customers');
};

It’s important to note that the value inside the ref needs to match the name of the declared mongoose model.

const dockQueueItem = new Mongoose.Schema({
  **pickables: [{ type: Mongoose.Schema.Types.ObjectId, ref: "pickable" }]**,
  loaded: { type: Boolean, default: false },
  track: [String],
});

const dockSchema = new Mongoose.Schema(
  {
    identifier: { type: String, unique: true },
    queue: [{ type: dockQueueItem }],
    createdAt: { type: Date, default: Date.now },
  },
  {
    timestamps: false,
  },
);

That is the declaration of my model ^^

Where are the lines with the call to mongoose.model?

In my example I first call const schema = Mongoose.Schema as you do with dockQueueItem = new Mongoose.Schema but at the end of the function, I return return mongoose.model('customers', schema, 'customers');.

The name of the collection in this call is important for references to be correctly interpreted by Forest Admin.

That’s why I’m asking for this declaration ; to check that everything is matching.