Tag: Push data sharing unsafe time format automatically deletes class init data type
In the project, the date type is created in MONGO, and the MONGO set expiration is automatically deleted based on the date type. and the date type in MONGO, using the ISO format, for example: Isodate ("2012-11-02t07:58:51.718z")
In Java, for example: Db.tianyc04.insert ({mark:1, mark_time:new date ()}), a new Date () is directly and easily done,
See {"_id": ObjectId ("5126e00939899c4cf3805f9b"), "Mark": 1, "Mark_time": Isodate ("2013-02-22t03:03:37.312z")} is like this.
In Erlang, however, there was no way to find the data type that was built into the MONGO in the beginning. After the string produced by the timestamp, it was created in the MONGO client to see that the discovery was of type string, and that this was clearly not in compliance with the requirements of MONGO automatically deleted according to the expiration time.
And after many attempts, I found that now () can be done.
Give me a chestnut:
Push_offline_msg_mongo_insert_all (Groupclientlist, pushmsgid), DbInfo = Push_op_mongo:init_dbinfo (), {MongoConn , DbName, Collection} = split_mh_android (DbInfo), Mongo:do (unsafe, Master, Mongoconn, DbName, Fun () Mongo:insert_all (collection,[{"mid", List_to_integer (Pushmsgid), "T", Token, "Sut", 0, "rut", 0, "out", 0, "Aut", 0, "cut" , now()} | | Token <-groupclientlist]) end.
Results under:
It's easy to get it done.
Erlang processing MongoDB Date time Format data type