Итак, я создал модель Client с ClientShema и сейчас я создаю модель Company. Одно из полей должно иметь тип Client, я пытался это сделать, но, похоже, происходит сбой
вот код:
const userSchema = new mongoose.Schema({
email: {
type: String,
},
username: {
type: String,
required: false
},
createdAt: {
type: Date,
required: true
},
_id: {
type: String,
required: false,
}
}, { collection: 'User' });
const User = mongoose.model('User', userSchema);
Вот мой файл, где я хочу использовать модель, предоставленную ранее.
const client = require('./client');
const companySchema = new mongoose.Schema({
_id: {
type: String,
required: true
},
logo: {
type: String,
required: false
},
companyName: {
type: String
},
clients: {
type: [client.Client]
}
}, { collection: 'Company' });
const Company = mongoose.model('Company', companySchema);