//bills collections
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
// Define collection and schema for Product
let bills = new Schema({
Id: { type: String },Name: { type: String },money: { type: Number },Perc: { type: String },Month: { type: String },branchName:{type: mongoose.Schema.Types.ObjectId,ref: 'branches'},},{
collection: 'bills'
});
module.exports = mongoose.model('bills',bills);
//branches collection
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
// Define collection and schema for Product
let branches = new Schema({
branchName: {
type: String
},{
collection: 'branches'
});
module.exports = mongoose.model('branches',branches);
如果我将Secunderabad作为branchName的branchName发送给账单集,则与分支集合_id中的Secunderabad相比,它保存了另一个ID 双子城是分支机构之一 然后我要成为相同的ID。