HelperFunctions  
Utility functions provided by LuaMongo
Updated Jul 27, 2010 by nr...@ii.net

Synopsis

require('mongo')

local date = mongo.Date(os.time() * 1000)
local newint = mongo.NumberInt(123)
local rx = mongo.RegEx('abc', 'gi')

print(mongo.type(date))             -- prints 'mongo.Date'
print(mongo.type(rx))               -- prints 'mongo.RegEx'
print(mongo.type({}))               -- prints 'table'
print(mongo.type('test'))           -- prints 'string'

local x = tonumber(newint)  + 10    -- x = 133
print(tonumber(rx))                 -- prints 'nil'
print(tonumber('test'))             -- prints 'nil'
print(tonumber('FF', 16))           -- prints '255'

Functions

typename = mongo.type(obj)

Returns a string name of the BSON type of obj. If obj is not a BSON object, returns the standard Lua type name.

num = mongo.tonumber(obj[, base])

Returns the number value represented by BSON data obj. If the value of obj cannot be converted into a number returns nil.

If obj is not a BSON data object behaves exactly the same as Lua's builtin tonumber.

::...
免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet


自怼圈/年度番新

DU22.4
关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::