As of now, you can’t. The from
field cannot be an expression and must be a string literal. However, there is an open issue which you can track here that appears to be exactly what you need: https://jira.mongodb.org/browse/SERVER-22497.
More Related Contents:
- Push items into mongo array via mongoose
- E11000 duplicate key error index in mongodb mongoose
- Mongoose: findOneAndUpdate doesn’t return updated document
- Mongoose populate vs object nesting
- Stop Mongoose from creating _id property for sub-document array items
- Why does mongoose always add an s to the end of my collection name
- Mongoose, update values in array of objects
- mongodb/mongoose findMany – find all documents with IDs listed in array
- Setting expiry time for a collection in mongodb using mongoose
- MongoError: The ‘cursor’ option is required, except for aggregate with the explain argument
- add created_at and updated_at fields to mongoose schemas
- Mongoose (mongodb) batch insert?
- Mongoose update without callback
- Mongoose populate nested array
- How to fix ‘Error: querySrv EREFUSED’ when connecting to MongoDB Atlas?
- How to define object in array in Mongoose schema correctly with 2d geo index
- Difference between MongoDB and Mongoose
- How to get all count of mongoose model?
- Mongoose: CastError: Cast to ObjectId failed for value “[object Object]” at path “_id”
- Model.find() returns empty in mongoose [duplicate]
- Mongoose – caused by :: 11000 E11000 duplicate key error index?
- log all queries that mongoose fire in the application
- Combine two OR-queries with AND in Mongoose
- Mongoose findOneAndUpdate and runValidators not working
- Populate a mongoose model with a field that isn’t an id
- Mongoose select fields to return from findOneAndUpdate
- mongoose recursive populate
- MongoDB $lookup vs Mongoose populate
- Heroku app crashes after MongoDB updated to 3.0
- Error at connecting to MongoDb Atlas Server