Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yorkie committed Nov 10, 2013
1 parent 1fc6fc8 commit 22a2cbf
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,51 @@
bson2v8
=======

deps: [mongodb-c-driver](https://github.com/mongodb/mongo-c-driver)
deps:
* [mongodb-c-driver](https://github.com/mongodb/mongo-c-driver)
* [v8](https://github.com/v8/v8)

purposes:

* Convert a `v8::Handle<v8::Value>` variable to a `bson*` type.
* Convert a `bson*` or `char*` means the buffer data of a `bson*` variable to a `v8::Local<v8::Value>`.

Convert from a bson to the v8 object, This project will help u to use mongodb better.

## API:

`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.

### Usage:

#### create a bson from `v8::Local<v8::Value>`
```c
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](https://github.com/mongodb/mongo-c-driver)
```c
Local<Object> return_v8_value(const char* buffer) {
// so easy, right?
return Utilities::ParseBSON(buffer);
}
```




## LICENSE

MIT
MIT, I'm so gald for this could help u :)

0 comments on commit 22a2cbf

Please sign in to comment.