Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here

lua-bson

A BSON library for lua

Subscribe to updates I use lua-bson


Statistics on lua-bson

Number of watchers on Github 74
Number of open issues 6
Average time to close an issue about 19 hours
Main language C
Average time to merge a PR less than a minute
Open pull requests 1+
Closed pull requests 1+
Last commit over 3 years ago
Repo Created about 7 years ago
Repo Last Updated over 2 years ago
Size 31 KB
Organization / Authorcloudwu
Contributors1
Page Updated
Do you use lua-bson? Leave a review!
View open issues (6)
View lua-bson activity
View on github
Fresh, new opensource launches πŸš€πŸš€πŸš€
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating lua-bson for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Introduction

This is a simple BSON library for Lua.

Building

make win

or

make linux

Types

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
bson.binary(blob) Binary string Use bson.type() to decode
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

Convert a bson value to lua string

A value with bson type Null,Binary,MinKey,Maxkey,etc would be encoded in lua, you can use bson.type(v) to convent back to normal lua string.

typestring, value = bson.type(bson.binary("Hello"))
assert(typestring == "binary")
assert(value == "Hello")

Replace field

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.

Getting started

See test.lua

lua-bson open issues Ask a question     (View All Issues)
  • over 4 years ε¦‚δ½•δ»Žε†…ε­˜ε—δΈ­θ―»ε–δΈ€δΈͺBSONε‘’οΌŸ
  • over 5 years windowsδΈ‹ηΌ–θ―‘ηΌΊε°‘linux倴文仢
  • over 6 years Luarocks
lua-bson open pull requests (View All Pulls)
  • add hex_dump
lua-bson list of languages used
Other projects in C