Erlang processing MongoDB Date time Format data type

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.