We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Do you want to request a feature or report a bug?
It's either a bug or an issue with the doc.
What is the current behavior?
I can't create the simple query helper from the doc. I have these 2 errors :
import { Document, Model, Query, Schema, connect, model } from 'mongoose'; interface Project { name: string; stars: number; } const schema = new Schema<Project>({ name: { type: String, required: true }, stars: { type: Number, required: true } }); // Query helpers should return `Query<any, Document<DocType>> & ProjectQueryHelpers` // to enable chaining. interface ProjectQueryHelpers { byName(name: string): Query<any, Document<Project>> & ProjectQueryHelpers; } schema.query.byName = function(name): Query<any, Document<Project>> & ProjectQueryHelpers { return this.find({ name: name }); }; // 2nd param to `model()` is the Model class to return. const ProjectModel = model<Project, Model<Project, ProjectQueryHelpers>>('Project', schema); run().catch(err => console.log(err)); async function run(): Promise<void> { await connect('mongodb://localhost:27017/test'); // Equivalent to `ProjectModel.find({ stars: { $gt: 1000 }, name: 'mongoose' })` await ProjectModel.find().where('stars').gt(1000).byName('mongoose'); }
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
{ "$schema": "https://json.schemastore.org/tsconfig", "display": "Node 14", "compilerOptions": { "lib": ["es2020"], "module": "commonjs", "target": "es2020", "strict": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true } }
The text was updated successfully, but these errors were encountered:
Does not happen on 6.3.0
Sorry, something went wrong.
3b943b2
docs(typescript): add coverage for TypeScript query helpers
6f951f3
Re: #11709
No branches or pull requests
Do you want to request a feature or report a bug?
It's either a bug or an issue with the doc.
What is the current behavior?
I can't create the simple query helper from the doc. I have these 2 errors :
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
The text was updated successfully, but these errors were encountered: