mongodb - How to query for Time less than another Time object in Volt with volt-mongo? -


i working on volt app needs compare times. using model looks this:

class punchcard < volt::model   field :punchtime end 

i can save instances of model time object punchtime , see persisted mongodb isodate() objects. far.

when want query database using less criteria, can see volt , volt-mongo turning call:

store.punchcards.where({"punchtime" => {"$lt" => punchtime}}).then... 

(where "punchtime" time object) mongo query:

db.punchcards.find({"punchtime": {"$lt": "2015-07-08t10:25:05-0700"}}) 

which returns no results though should.

when trace insert call when saving instance of punchcard model, see time object not stringified:

[info] task storetasks#save in 11.557ms args: "punchcards", ["punchcards", "[]"], {"user_id"=>"925b0eb84bc3d2185d1c693a", "punchtime"=>2015-07-08 16:38:49 -0700, "punch_status"=>"out", "id"=>"75c1a3c35016d30895d38d28"} 

therefore, i'm guessing since time object stringified on find call not on save call, mongo doing string comparison on find.

how can query mongo $lt / $gt , time objects in volt?

this should fixed on master. try running master , let me know if works.

gem 'volt', github: 'voltrb/volt' 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -