Hi everyone,
I am new to both NodeJS and ForestAdmin and all that includes, I have done other programming before like, PHP Javascript and jquery so I am not new to programming.
I have one collection of Customer and another one which is called CustomerContacts, both those are linked together so that when entering a customer I can see all the CustomerContacts which belongs to this Customer.
I also have a collection called Cases, and I want to be able to select CustomerContacts based on which Customer i have selected in the drowndown, ergo, I want to only get the CustomerContacts which belongs to the Customer I selected in the Customer dropdown.
I have searched for several days but are not able to find anythings that fits my needs.
The Case collection has relations to Customer and CustomerContacts so that is all done.
Case collection
const schema = mongoose.Schema({
'customers': { type: mongoose.Schema.Types.ObjectId, ref: 'customers' },
'customerContacts': { type: mongoose.Schema.Types.ObjectId, ref: 'customerContacts' },
},{
timestamps: true,
});
module.exports = mongoose.model('case', schema, 'case');
Also, in the Case view I want to show a field from the Customer collection called Instructions, but cant figure out how to do this.
Customer collection
const schema = mongoose.Schema({
'name': String,
'instructions': String,
'createdAt': Date,
'customerContacts': [{ type: mongoose.Schema.Types.ObjectId, ref: 'customerContacts' }],
}, {
timestamps: true,
});
module.exports = mongoose.model('customers', schema, 'customers');
Can anyone please help me or atleast point me in the right direction?
Thanks in advance!