Skip to content

support mongoc 2.x #48

Description

@baidwwy

https://github.com/mongodb/mongo-c-driver/blob/632143bf35a309052481f16afe3ee4260360ad05/src/libbson/NEWS#L136-L139

lua-mongo/src/bson.c

Lines 64 to 70 in 74f15a0

static int m__tostring(lua_State *L) {
size_t len;
char *str = bson_as_json(checkBSON(L, 1), &len);
lua_pushlstring(L, str, len);
bson_free(str);
return 1;
}

static int m__tostring(lua_State *L) {
	size_t len;
#if BSON_MAJOR_VERSION == 1
	char* str = bson_as_json(checkBSON(L, 1), &len);
#elif BSON_MAJOR_VERSION == 2
	char *str = bson_as_legacy_extended_json(checkBSON(L, 1), &len);
#endif
	lua_pushlstring(L, str, len);
	bson_free(str);
	return 1;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions