Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongo Date type supported? #53

Open
sunao-uehara opened this issue Jul 21, 2016 · 1 comment
Open

Mongo Date type supported? #53

sunao-uehara opened this issue Jul 21, 2016 · 1 comment

Comments

@sunao-uehara
Copy link

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

@narate
Copy link

narate commented Aug 11, 2016

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants