lua-resty-mongol icon indicating copy to clipboard operation
lua-resty-mongol copied to clipboard

Mongo Date type supported?

Open sunao-uehara opened this issue 9 years ago • 1 comments

It seems there is a issue inserting Date type. For instance, I have a code to create new user with created_at field.

local mongo = require "resty.mongol"
local bson = require "resty.mongol.bson"

local now = bson.get_utc_date(ngx.time() * 1000)
local data = {
    user = 1,
    created_at = now
}
local db, err = mongo:new(XXXXX)
local user = db:get_col("user")
local res, err = user:insert({data}, nil, true)

Data stored in created_at is actually {"v"=>1469128796000} and the value 1469128796000 is stored as int64 type, not mongo's Date type. Does anybody has same issue or a suggestion to fix it?

Thanks

sunao-uehara avatar Jul 21 '16 19:07 sunao-uehara

local now = bson.get_utc_date(ngx.now() * 1000)

ngx.now() It's work for me.

narate avatar Aug 11 '16 09:08 narate