-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Limit isn't applied when a string is informed #11017
Labels
enhancement
This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Milestone
Comments
wesleimarinho
changed the title
Limit isn't applyied when a string is informed
Limit isn't applied when a string is informed
Nov 26, 2021
IslandRhythms
added
the
can't reproduce
Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.
label
Nov 29, 2021
Works fine for me const mongoose = require('mongoose');
const {Schema} = mongoose;
const testSchema = new Schema({
file: Number
});
const Test = mongoose.model('Test', testSchema);
async function run() {
await mongoose.connect('mongodb://localhost:27017/', {useNewUrlParser: true,
useUnifiedTopology: true,});
await mongoose.connection.dropDatabase();
for (let i = 0; i < 20; i++) {
await Test.create({file: i});
}
console.log(await Test.find().limit(5));
console.log(await Test.find({},null,{limit: 5}));
}
run(); |
Proper test case, according to the issue description is: const mongoose = require('mongoose');
const {Schema} = mongoose;
const testSchema = new Schema({
file: Number
});
const Test = mongoose.model('Test', testSchema);
async function run() {
await mongoose.connect('mongodb://localhost:27017/', {useNewUrlParser: true,
useUnifiedTopology: true,});
await mongoose.connection.dropDatabase();
for (let i = 0; i < 20; i++) {
await Test.create({file: i});
}
console.log(await Test.find().limit(String.valueOf(5)));
console.log(await Test.find({},null,{limit: '5'}));
}
run(); |
IslandRhythms
added
help
This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary
and removed
can't reproduce
Mongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.
labels
Nov 30, 2021
It expects a number, so putting a string is an improper use. |
vkarpov15
added
enhancement
This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
and removed
help
This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary
labels
Jan 4, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Do you want to request a feature or report a bug?
doubt
What is the current behavior?
If I use
{limit:'2'}
orlimit('2')
the option isn't apllied (or a variable with string value instead of Number).Is this the exptected behavior?
There is no information about this on https://mongoosejs.com/docs/api/query.html#query_Query-limit, despite mentioning it is expected a number.
The text was updated successfully, but these errors were encountered: