Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道 Waterline 的关联功能,但是对于这个特定的应用程序,我不想使用它(我不希望在我的 JSON 中返回相关模型——我只想要它们的 ObjectId)。
有没有办法在我的模型上创建一个类型为 ObjectId 的字段而不使用关联?
您可以通过简单地不填充它来返回关联的 objectId。
如果我有一个带宠物的主人。
Owner.Find(1).populate('pet).exec(...) 将返回带有宠物的用户作为对象。
如果你只是使用
Owner.Find(1).exec(...) 将返回带有宠物的用户作为 objectId