Closed William-Hill closed 2 years ago
can you paste that schemas and admin-bro config?
The admin-bro config is as follows
const AdminBroOptions = { resources: ['Contact', 'Email', 'Phone', 'URL'], rootPath: "/admin", };
The schemas are below:
export const emailSchema: mongoose.Schema = new mongoose.Schema({
order: { type: Number, default: 0 },
email: { type: String, match: [/\S+@\S+\.\S+/, "is invalid"], maxlength: 250 },
timestamp: { type: Date, default: Date.now },
}, { collection: "contact_email", _id: false });
const contactSchema: mongoose.Schema = new mongoose.Schema({
name: { type: String, required: true, match: [/^[a-zA-Z0-9]+$/, "is invalid"], maxlength: 250 },
jobTitle: { type: String, maxlength: 250 },
organization: { type: String},
description: { type: String},
address: { type: String },
category: { type: mongoose.Schema.Types.ObjectId, ref: "ContactCategory" },
group: { type: mongoose.Schema.Types.ObjectId, ref: "ContactGroup" },
order: { type: Number, default: 0},
email: { type: [emailSchema], default: [] },
phone: {type: [phoneSchema], default: [] },
fax: { type: [faxSchema], default: [] },
url: { type: [urlSchema], default: [] },
timestamp: { type: Date, default: Date.now }
}, {collection: "contact"});
The phone and fax schemas are similar to the email schema.
The category and group are working fine as foreign keys, but I'm only having problems with the subdocuments
sorry for the late response - will try to debug that this week and let you know
Hi all. Was this resolved? I have the same issue, any help is welcome. Thanks in advance!
we are making lots of improvements/bug fixes regarding nested arrays/schemas. So this should probably go away in v3.3 (currently in beta)
3.3 was released a long time ago so this should've been fixed. Please open another issue if you're still having problem with your case.
I have a schema called Contact and another Schema called email that is a subdocument of Contact. The Contact schema can hold an array of emails.
When attempting to add a new instance of email, I get the following error in the AdminBro UI:
this.ownerDocument(...).model is not a function
.The error shows up on the ID field of the email subdocument
How can this be fixed?