更新时间:2022-03-18 04:34:22
最常见的方法是在您的应用程序中创建一个映射层来接收一组字段,然后将它们映射到您的应用程序需要的内容.
The most common approach is to make a mapping layer in your application to take in a set of fields and then map them to what your application needs.
您说得对,MongoDB 中根本没有内置 AS
投影.
You are correct that there is not AS
projection built into MongoDB at all.
我相信您可以通过聚合来实现这一点:
I believe you could accomplish this with the aggregation however:
所以是的,我会坚持在应用程序中编写映射类.
So yea, I would stick to writing a mapping class in the app.