-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mongoose typings broke the example #7
Labels
Comments
@rpenido can you please provide a code sample that demonstrates the issue you're seeing? |
The code in README of this repo, for example: mongoose:
|
It will run correctly but the typing error is there. import * as mongoose from 'mongoose';
import * as assert from 'assert';
const mongooseLeanId = require('mongoose-lean-id');
const testSchema = new mongoose.Schema({
name: String
});
testSchema.plugin(mongooseLeanId);
const Test = mongoose.model('Test', testSchema);
async function run() {
await mongoose.connect('mongodb://localhost:27017');
await mongoose.connection.dropDatabase();
await Test.create({ name: 'test' });
const findRes = await Test.find().lean();
const findOneRes = await Test.findOne().lean();
const findOneAndUpdateRes = await Test.findOneAndUpdate({}, { name: 'test' }).lean();
assert.equal(findRes[0].id, findRes[0]._id.toHexString());
assert.equal(findOneRes.id, findOneRes._id.toHexString());
assert.equal(findOneAndUpdateRes.id,
findOneAndUpdateRes._id.toHexString());
console.log('done');
}
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Running the example gives the following type error:
Property 'id' does not exist on type 'LeanDocument<{ name?: string; } & { _id: ObjectId; }>'.
I think that it is related to this: Automattic/mongoose#11761
Don't know if this can be solved in the plugin level.
The text was updated successfully, but these errors were encountered: