Skip to content

Commit bc1c84c

Browse files
committed
Merge pull request #45 from moai/develop
Version 0.5.0
2 parents ba33091 + 6dcd552 commit bc1c84c

File tree

10 files changed

+245
-426
lines changed

10 files changed

+245
-426
lines changed

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ AR= ar rcu
88
RANLIB= ranlib
99
RM= rm -f
1010
OUTLIB= mongo.so
11-
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
11+
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
1212

1313
# macports
1414
ifneq ("$(wildcard /opt/local/include/mongo/client/dbclient.h)","")
@@ -98,9 +98,7 @@ mongo_bsontypes.o: mongo_bsontypes.cpp common.h
9898
$(CC) -c -o $@ $< $(CFLAGS)
9999
utils.o: utils.cpp common.h utils.h
100100
$(CC) -c -o $@ $< $(CFLAGS)
101-
mongo_cxx_extension.o: mongo_cxx_extension.cpp mongo_cxx_extension.h
102-
$(CC) -c -o $@ $< $(CFLAGS)
103-
mongo_gridfilebuilder.o: mongo_gridfilebuilder.cpp mongo_cxx_extension.h common.h utils.h
101+
mongo_gridfilebuilder.o: mongo_gridfilebuilder.cpp common.h utils.h
104102
$(CC) -c -o $@ $< $(CFLAGS)
105103

106104
.PHONY: all check checkdarwin clean DetectOS Linux Darwin echo

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# A Lua driver for mongodb
22

3+
## Versions compatibility
4+
5+
| luamongo | mongo-c++-driver |
6+
| -------- | ---------------- |
7+
| v0.4.5 | legacy-0.9.0 |
8+
| v0.5.0 | legacy-1.1.0 |
9+
10+
Version 1.0.0 is expected when the modern c++ driver is marked as stable. See
11+
at the end of this file what changes are introduced from v0.4.5 to v0.5.0.
12+
313
## Compilation
414

515
The makefile automatically detects which platform and Lua version are you
@@ -128,3 +138,21 @@ external_deps_dirs = {
128138
},
129139
}
130140
```
141+
142+
## Changes from v0.4.5 to v0.5.0
143+
144+
- `GridFileBuilder` has been introduced into legacy C++ driver, luamongo don't
145+
implements it any more. The constructor has been changed and now it only
146+
receives an instance of GridFS class.
147+
148+
- `db:ensure_index()` function has been replaced by `db:create_index()`. The
149+
parameters of the new function are `create_index(ns,keys,options)` where
150+
`keys` and `options` can be Lua tables or JSON strings (both dictionaries
151+
which allow 'unique' and 'name' fields).
152+
153+
- `db:get_indexes()` is now `db:enumerate_indexes()`.
154+
155+
- `db:reset_index_cache()` has been removed.
156+
157+
- `gridfs:find_file()` requires a query. It has been added
158+
`gridfs:find_file_by_name(filename)` equivalent to old implementation.

common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define LUAMONGO_NAME "mongo"
22
#define LUAMONGO_NAME_STRING "_NAME"
3-
#define LUAMONGO_VERSION "0.4"
3+
#define LUAMONGO_VERSION "0.5"
44
#define LUAMONGO_VERSION_STRING "_VERSION"
55

66
#define LUAMONGO_ROOT "mongo"

main.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <iostream>
2525
#include <client/dbclient.h>
26+
#include <client/init.h>
2627
#include <sys/time.h>
2728
#include "utils.h"
2829
#include "common.h"
@@ -55,6 +56,17 @@ int mongo_time(lua_State *L) {
5556
return 1;
5657
}
5758

59+
struct Initializer {
60+
mongo::client::GlobalInstance *instance;
61+
Initializer() : instance(0) { }
62+
~Initializer() { delete instance; }
63+
void init() {
64+
instance = new mongo::client::GlobalInstance();
65+
instance->assertInitialized();
66+
}
67+
};
68+
Initializer initializer;
69+
5870
/*
5971
*
6072
* library entry point
@@ -69,7 +81,9 @@ LM_EXPORT int luaopen_mongo(lua_State *L) {
6981
{"time", mongo_time},
7082
{NULL, NULL}
7183
};
72-
84+
85+
initializer.init();
86+
7387
// bsontypes is the root table
7488
mongo_bsontypes_register(L);
7589

mongo_cxx_extension.cpp

Lines changed: 0 additions & 178 deletions
This file was deleted.

mongo_cxx_extension.h

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)