deps:
purposes:
- Convert a
v8::Handle<v8::Value>
variable to abson*
type. - Convert a
bson*
orchar*
means the buffer data of abson*
variable to av8::Local<v8::Value>
.
ParseBSON(const char* buffer)
provide u can pass a bson raw data.
ParseBSON(const bson* buffer)
provide u can pass a bson object.
ToBSON(Local<Value> in, bson* out)
provide u can pass 1 in v8::Value and out a bson* pointer.
Handle<Value> create_bson(const Arguments& args) {
// create a bson
bson* b = bson_alloc();
Utilities::ToBSON(args[0], result);
// now u can print the bson result
bson_print(b);
// the end, remember destroy this bson heap
bson_destroy(b);
}
get a v8::Local<v8::Object>
from a bson in mongo-c-driver
Local<Object> return_v8_value(const char* buffer) {
// so easy, right?
return Utilities::ParseBSON(buffer);
}
MIT, I'm so gald for this could help u :)