本文介绍了猫鼬(mongodb)别名_id字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
猫鼬是否可以使用其他名称(在我的情况下为大写"ID")作为架构_id字段的别名?我需要添加一个虚拟的还是有另一种设置方法?
Is it possible with mongoose use a different name, in my case uppercase 'ID', as an alias for the schema _id field?Would I need to add a virtual or is there another way of setting this up?
任何帮助都感激不尽.
推荐答案
您应将虚拟属性用于那.如:
yourSchema.virtual('ID').get(function() { return this._id; });
这篇关于猫鼬(mongodb)别名_id字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!