You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lett;letalarms=[];for(leti=0;i<80000;i++){letid="74590869096"+(907836+i);alarms.push({id,name: 'hello'+i});}vardb=newloki('exampleDB');varalarmCollection=db.addCollection('myAlarms',{unique: ['id']});t=Date.now();alarms.forEach(obj=>alarmCollection.insert(obj));console.log(`完成插入 耗时${(Date.now()-t)/1000}s alarmCollection.count=${alarmCollection.count()}`);letexample=alarmCollection.chain().compoundsort(['id']).offset(50000).limit(1).data()[0];letexampleId=example.id;console.log('exampleId',exampleId)t=Date.now();console.log('count jlt exampleId by lokijs',alarmCollection.count({id: {$jlt: exampleId}}),`, 耗时${(Date.now()-t)/1000}s`);t=Date.now();console.log('count jlte exampleId by lokijs',alarmCollection.count({id: {$jlte: exampleId}}),`, 耗时${(Date.now()-t)/1000}s`);t=Date.now();console.log('count jgt exampleId by lokijs',alarmCollection.count({id: {$jgt: exampleId}}),`, 耗时${(Date.now()-t)/1000}s`);t=Date.now();console.log('count lt exampleId by js',alarms.filter(a=>(a.id<exampleId)).length,`, 耗时${(Date.now()-t)/1000}s`);t=Date.now();console.log('count lte exampleId by js',alarms.filter(a=>(a.id<=exampleId)).length,`, 耗时${(Date.now()-t)/1000}s`);t=Date.now();console.log('count gt exampleId by js',alarms.filter(a=>(a.id>exampleId)).length,`, 耗时${(Date.now()-t)/1000}s`);t=Date.now();console.log('count lt exampleId by lokijs',alarmCollection.count({id: {$lt: exampleId}}),`, 耗时${(Date.now()-t)/1000}s`);t=Date.now();console.log('count lte exampleId by lokijs',alarmCollection.count({id: {$lte: exampleId}}),`, 耗时${(Date.now()-t)/1000}s`);t=Date.now();console.log('count gt exampleId by lokijs',alarmCollection.count({id: {$gt: exampleId}}),`, 耗时${(Date.now()-t)/1000}s`);
result:
完成插入 耗时0.101s alarmCollection.count=80000
exampleId 74590869096957836
count jlt exampleId by lokijs 50000 , 耗时0.005s
count jlte exampleId by lokijs 50001 , 耗时0.005s
count jgt exampleId by lokijs 29999 , 耗时0.004s
count lt exampleId by js 50000 , 耗时0.002s
count lte exampleId by js 50001 , 耗时0.002s
count gt exampleId by js 29999 , 耗时0.002s
count lt exampleId by lokijs 49997 , 耗时0.018s
count lte exampleId by lokijs 50012 , 耗时0.015s
count gt exampleId by lokijs 29988 , 耗时0.016s
as we can see, count lte exampleId shoud be 50001, es6 and $jlte return correct result, but lokijs's $lte returns 50012.
The text was updated successfully, but these errors were encountered:
qiangbro
changed the title
Wrong result while quering by $lt/lte/gte with a large numeric string
Wrong result while quering by $lt/lte/gte with a large numeric string property
Mar 1, 2022
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
my code:
result:
as we can see,
count lte exampleId
shoud be 50001, es6 and $jlte return correct result, but lokijs's $lte returns 50012.The text was updated successfully, but these errors were encountered: