Skip to content

Commit

Permalink
Merge pull request #45 from moai/develop
Browse files Browse the repository at this point in the history
Version 0.5.0
  • Loading branch information
pakozm committed Dec 22, 2015
2 parents ba33091 + 6dcd552 commit bc1c84c
Show file tree
Hide file tree
Showing 10 changed files with 245 additions and 426 deletions.
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ AR= ar rcu
RANLIB= ranlib
RM= rm -f
OUTLIB= mongo.so
OBJS = main.o mongo_bsontypes.o mongo_dbclient.o mongo_replicaset.o mongo_connection.o mongo_cursor.o mongo_gridfile.o mongo_gridfs.o mongo_gridfschunk.o mongo_query.o utils.o mongo_cxx_extension.o mongo_gridfilebuilder.o
OBJS = main.o mongo_bsontypes.o mongo_dbclient.o mongo_replicaset.o mongo_connection.o mongo_cursor.o mongo_gridfile.o mongo_gridfs.o mongo_gridfschunk.o mongo_query.o utils.o mongo_gridfilebuilder.o

# macports
ifneq ("$(wildcard /opt/local/include/mongo/client/dbclient.h)","")
Expand Down Expand Up @@ -98,9 +98,7 @@ mongo_bsontypes.o: mongo_bsontypes.cpp common.h
$(CC) -c -o $@ $< $(CFLAGS)
utils.o: utils.cpp common.h utils.h
$(CC) -c -o $@ $< $(CFLAGS)
mongo_cxx_extension.o: mongo_cxx_extension.cpp mongo_cxx_extension.h
$(CC) -c -o $@ $< $(CFLAGS)
mongo_gridfilebuilder.o: mongo_gridfilebuilder.cpp mongo_cxx_extension.h common.h utils.h
mongo_gridfilebuilder.o: mongo_gridfilebuilder.cpp common.h utils.h
$(CC) -c -o $@ $< $(CFLAGS)

.PHONY: all check checkdarwin clean DetectOS Linux Darwin echo
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# A Lua driver for mongodb

## Versions compatibility

| luamongo | mongo-c++-driver |
| -------- | ---------------- |
| v0.4.5 | legacy-0.9.0 |
| v0.5.0 | legacy-1.1.0 |

Version 1.0.0 is expected when the modern c++ driver is marked as stable. See
at the end of this file what changes are introduced from v0.4.5 to v0.5.0.

## Compilation

The makefile automatically detects which platform and Lua version are you
Expand Down Expand Up @@ -128,3 +138,21 @@ external_deps_dirs = {
},
}
```

## Changes from v0.4.5 to v0.5.0

- `GridFileBuilder` has been introduced into legacy C++ driver, luamongo don't
implements it any more. The constructor has been changed and now it only
receives an instance of GridFS class.

- `db:ensure_index()` function has been replaced by `db:create_index()`. The
parameters of the new function are `create_index(ns,keys,options)` where
`keys` and `options` can be Lua tables or JSON strings (both dictionaries
which allow 'unique' and 'name' fields).

- `db:get_indexes()` is now `db:enumerate_indexes()`.

- `db:reset_index_cache()` has been removed.

- `gridfs:find_file()` requires a query. It has been added
`gridfs:find_file_by_name(filename)` equivalent to old implementation.
2 changes: 1 addition & 1 deletion common.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define LUAMONGO_NAME "mongo"
#define LUAMONGO_NAME_STRING "_NAME"
#define LUAMONGO_VERSION "0.4"
#define LUAMONGO_VERSION "0.5"
#define LUAMONGO_VERSION_STRING "_VERSION"

#define LUAMONGO_ROOT "mongo"
Expand Down
16 changes: 15 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <iostream>
#include <client/dbclient.h>
#include <client/init.h>
#include <sys/time.h>
#include "utils.h"
#include "common.h"
Expand Down Expand Up @@ -55,6 +56,17 @@ int mongo_time(lua_State *L) {
return 1;
}

struct Initializer {
mongo::client::GlobalInstance *instance;
Initializer() : instance(0) { }
~Initializer() { delete instance; }
void init() {
instance = new mongo::client::GlobalInstance();
instance->assertInitialized();
}
};
Initializer initializer;

/*
*
* library entry point
Expand All @@ -69,7 +81,9 @@ LM_EXPORT int luaopen_mongo(lua_State *L) {
{"time", mongo_time},
{NULL, NULL}
};


initializer.init();

// bsontypes is the root table
mongo_bsontypes_register(L);

Expand Down
178 changes: 0 additions & 178 deletions mongo_cxx_extension.cpp

This file was deleted.

73 changes: 0 additions & 73 deletions mongo_cxx_extension.h

This file was deleted.

Loading

0 comments on commit bc1c84c

Please sign in to comment.