sift.js
sift.js copied to clipboard
bson support?
Is it possible to query raw bson using this library? Or can this library be helpful to achieve such a goal: searching a big amount of raw data without a whole parsing.
I think Sift should work how you want it to -- do you have a pseudocode example?
I think Sift should work how you want it to -- do you have a pseudocode example?
I can use it like:
let jsData=parse(bson) // maybe bson is 100M and more, costing a lot of cpu
let result=sift(jsData)
But I want:
let result=sift(bson)
To achieve that, sift should have the ability to directly access bson.
Does the compare
option help solve your problem? For example:
const compare = (a, b) => {
if (a instanceof BSONObject && b instanceof BSONObject) {
reutrn a.value === b.value;
}
}
sift({ $eq: someBSONObject }, { compare });
I understand it can't be answered by sift, but I ask it here anyway.
I can use it like:
const test = sift({ a:{ $exists: true } }));
test({a:1});
But I want:
const test = sift({ a:{ $exists: true } }));
const bson = BSON.serialize({ a:1 }); // Buffer instance
test(bson);
BSON Buffer is designed to be queriable, it's reasonable to ask to directly query a buffer.
happy to include this functionality in sift if you want to create a PR!
Closing this since it's a bit stale. Happy to re-open if this is still an issue.