Comments (3)
Please modify the script below to demonstrate your issue:
const mongoose = require('mongoose');
const testSchema = new mongoose.Schema({
name: String
}, { id: true, timestamps: true, toJSON: { virtuals: true, versionKey: false, transform(doc,ret) { delete ret._id ;}}})
const otherSchema = new mongoose.Schema({
name: String,
testId: mongoose.Schema.Types.ObjectId
});
otherSchema.virtual('entry', { ref: 'Test', localField: 'testId', foreignField: '_id', justOne: true });
const Test = mongoose.model('Test', testSchema);
const Other = mongoose.model('Other', otherSchema);
async function run() {
await mongoose.connect('mongodb://localhost:27017');
await mongoose.connection.dropDatabase();
const doc = await Test.create({
name: 'Test Testerson'
});
const other = await Other.create({
name: 'Other Otherson',
testId: doc._id
});
const res = await Other.findOne().populate('entry');
console.log('what is res', res, res.entry);
}
run();
from mongoose.
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days
from mongoose.
This issue was closed because it has been inactive for 19 days and has been marked as stale.
from mongoose.
Related Issues (20)
- Typescript sees the Boolean Constructor Type as Date when using Mongoose HOT 6
- getting _id as unknown type HOT 5
- "operation-start" event of the MongooseConnection
- Mismatch between the type derived from the ```lean``` query and the declared interface on virtual fields HOT 3
- Documentation site down? HOT 1
- Type 'import(".../node_modules/mongoose/node_modules/mongodb/mongodb").MongoClient' is not assignable to type 'import(".../node_modules/mongodb/mongodb").MongoClient'. HOT 7
- BSON Timestamp in a mongoose schema
- The return type of connection.tranaction method should not be Promise<void>.
- [Feature] Add option to disable filters on each method HOT 2
- InferRawDocType returns `unknown` for every property instead of the right type HOT 1
- TS: _id not required on DocumentArray properties of documents returned from query HOT 3
- Embedded documents are missing the `toJSON()` method HOT 1
- Can not creating a Schema with a field named 'parent' HOT 4
- Query recursive model with discriminator not working with string ref id filter HOT 1
- await mongoose.connect() not fully connected HOT 3
- how to search objectid with regex? HOT 3
- địt con bà chúng mày
- Example for findOneAndUpdate is confusing HOT 2
- Unable to use `$pull` on nested array within discriminated union
- Document.prototype.validate() does not validate subdocument required fields with validateModifiedOnly option HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongoose.