• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

cloudwu/lua-bson: A BSON library for lua

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

cloudwu/lua-bson

开源软件地址(OpenSource Url):

https://github.com/cloudwu/lua-bson

开源编程语言(OpenSource Language):

C 91.4%

开源软件介绍(OpenSource Introduction):

Introduction

This is a simple BSON library for Lua.

Building

make win

or

make linux

Types

Lua TypeBSON TypeNotes
bson.nullNull
booleanBoolean
numberDouble
number32-bit integer
number64-bit integerprecision lost in lua 5.1/5.2
stringString
bson.binary(blob)Binary stringUse bson.type() to decode
tableBSON Document
tableBSON ArrayLua table must be a sequence. (Continuous number key base 1)
bson.date(os.time())UTC Datetimemilliseconds since epoch
bson.timestamp(os.time())Timestampspecial mongodb type, two 32-bit number
bson.regex(regex,option)Regular Expression
bson.objectid()ObjectIDMongoDB document ID
bson.minkeyMin Key
bson.maxkeyMax 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




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
cloudwu/luabind: simple and robust lua binding lib发布时间:2022-08-16
下一篇:
arcticfox1919/LuaDardo: A Lua virtual machine written in Dart发布时间:2022-08-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap