Handle<Value> ObjectID::ToString(const Arguments &args) { ObjectID *o = ObjectWrap::Unwrap<ObjectID>(args.This()); HandleScope scope; char hex[25]; o->str(hex); return String::New(hex); }
void encodeObjectID(bson_buffer *bb, const char *name, const Local<Value> element) { // get at the delicious wrapped object centre Local<Object> obj = element->ToObject(); assert(!obj.IsEmpty()); assert(obj->InternalFieldCount() > 0); ObjectID *o = static_cast<ObjectID*>(Handle<External>::Cast( obj->GetInternalField(0))->Value()); bson_oid_t oid; char oid_hex[25]; o->str(oid_hex); bson_oid_from_string(&oid, oid_hex); bson_append_oid(bb, name, &oid); }