- compatible with luajit-2.0 via https://github.com/keplerproject/lua-compat-5.2
- wraps strings to avoid errors while calling cbson.type(string) if '\0' control byte in normal string
This is a simple BSON library for Lua.
make win
or
make linux
Lua Type | BSON Type | Notes |
---|---|---|
bson.null | Null | |
boolean | Boolean | |
number | Double | |
number | 32-bit integer | |
number | 64-bit integer | precision lost in lua 5.1/5.2 |
string | String | |
table | BSON Document | |
table | BSON Array | Lua table must be a sequence. (Continuous number key base 1) |
bson.date(os.time()) | UTC Datetime | milliseconds since epoch |
bson.timestamp(os.time()) | Timestamp | special mongodb type, two 32-bit number |
bson.regex(regex,option) | Regular Expression | |
bson.objectid() | ObjectID | MongoDB document ID |
bson.minkey | Min Key | |
bson.maxkey | Max Key |
These bson types (fixed length) below can be replace by new value after encode to bson object.
- int32
- int64
- double
- boolean
- date
- timestamp
- objectid
You need call makeindex() before replace.
See test.lua