forked from mSOHU/lua-bson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.lua
More file actions
45 lines (36 loc) · 719 Bytes
/
test.lua
File metadata and controls
45 lines (36 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
bson = require "bson"
sub = bson.encode_order( "hello", 1, "world", 2 )
b = bson.encode {
a = 1,
b = true,
c = bson.null,
d = { 1,2,3,4 },
e = bson.binary "hello",
f = bson.regex ("*","i"),
g = bson.regex "hello",
h = bson.date (os.time()),
i = bson.timestamp(os.time()),
j = bson.objectid(),
k = { a = false, b = true },
l = {},
m = bson.minkey,
n = bson.maxkey,
o = sub,
p = 2^32-1,
}
t = b:decode()
for k,v in pairs(t) do
print(k, bson.type(v))
end
b:makeindex()
b.a = 2
b.b = false
b.h = bson.date(os.time())
b.i = bson.timestamp(os.time())
b.j = bson.objectid()
print "after replace"
t = b:decode()
for k,v in pairs(t) do
print(k, bson.type(v))
end
print("o.hello", bson.type(t.o.hello))