Closed youyinnn closed 4 years ago
@youyinnn If you have a solution to this problem maybe you could update the issue so other people like me can find it :D
@nshCore hi, I fixed this problem by finding out a mistake of my code.
when it was performing the function .find({ name: name })
, the value name
should be a basic type like number or string or boolean, while in my wrong case, I was passing an object name
in it, so I got the error log like:
D:\Workshop\MyNodejs\node_modules\lokijs\src\lokijs.js:3519
if (fun(t[i][property], value)) {
^
TypeError: fun is not a function
at Resultset.find (D:\Workshop\MyNodejs\node_modules\lokijs\src\lokijs.js:3519:19)
at Collection.find (D:\Workshop\MyNodejs\node_modules\lokijs\src\lokijs.js:6797:27)
at runProgramLogic (D:\Workshop\MyNodejs\practices\lokijs\core.js:41:20)
at databaseInitialize (D:\Workshop\MyNodejs\practices\lokijs\core.js:18:5)
at D:\Workshop\MyNodejs\node_modules\lokijs\src\lokijs.js:2626:15
at loadDatabaseCallback (D:\Workshop\MyNodejs\node_modules\lokijs\src\lokijs.js:2542:15)
at readFileCallback (D:\Workshop\MyNodejs\node_modules\lokijs\src\lokijs.js:2348:15)
at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:61:3)
so if you got this error please use the basic type values as keys to index your record:
result = users.find({
name: 'mike'
});
instead of:
result = users.find({
name: { name: 'mike' }
});
perform in
.find({ name: name })