Skip to content
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

bson support? #215

Open
jinCN opened this issue Sep 30, 2020 · 6 comments
Open

bson support? #215

jinCN opened this issue Sep 30, 2020 · 6 comments

Comments

@jinCN
Copy link

jinCN commented Sep 30, 2020

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.

@crcn
Copy link
Owner

crcn commented Nov 5, 2020

I think Sift should work how you want it to -- do you have a pseudocode example?

@jinCN
Copy link
Author

jinCN commented Nov 8, 2020

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.

@crcn
Copy link
Owner

crcn commented Dec 27, 2020

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 });

@jinCN
Copy link
Author

jinCN commented Jan 21, 2021

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.

@crcn
Copy link
Owner

crcn commented Jul 28, 2021

happy to include this functionality in sift if you want to create a PR!

@crcn
Copy link
Owner

crcn commented Oct 30, 2022

Closing this since it's a bit stale. Happy to re-open if this is still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants