简体   繁体   English

mongoose快递节点JS链接二合集不使用_id

[英]mongoose express node JS link two collection without using _id

hello I have two collection one called room and second called booking I have RoomID as a attribute and I want to link room id as a primary key from collection room with RoomID in collection booking in mongoose with express and node JS one room has many booking...?您好,我有两个集合,一个称为房间,第二个称为预订..?

There is nothing such concept of Primary Key in mongodb (mongoose) but in Relational Databases like: MySQL, PGSQL and so on. mongodb(猫鼬)中没有Primary Key的概念,但在关系数据库中,如:MySQL、PGSQL 等。

Even if you want to do so, you can use that in find operation simply like:即使你想这样做,你也可以在 find 操作中使用它,就像:

const bookings = await BookingModel.find({RoomID: inputRoomID});

This way you can get bookings for a simple room with inputRoomID and If you want to go further ie bookings for all rooms, go for aggregation in mongoose.通过这种方式,您可以获得带有inputRoomID的简单房间的预订,如果您想要 go 进一步,即所有房间的预订,go 用于在 Z758D31F351CE11BF27C522F516CB4C2 中aggregation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM