You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Paco Zamora Martinez edited this page Jun 13, 2014
·
3 revisions
##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.
mongo.sleep(double)
Sleep function which wraps C nanosleep function, it receives a double indicating
in seconds the sleep duration.
t = mongo.time()
Time function which wraps C gettimeofday function, it returns a double which is
a timestamps in seconds with nanoseconds resolution.
###Example
localmongo=require('mongo')
localdate=mongo.Date(os.time() *1000)
localnewint=mongo.NumberInt(123)
localrx=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'localx=tonumber(newint) +10-- x = 133print(tonumber(rx)) -- prints 'nil'print(tonumber('test')) -- prints 'nil'print(tonumber('FF', 16)) -- prints '255'print(mongo.time())
mongo.sleep(10)