如何根据日期自动将集合添加到mongodb? [英] How to add collections to mongodb automatically based on date?
本文介绍了如何根据日期自动将集合添加到mongodb?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用MEAN堆栈开发开发旅行预订网站。门票预订可在旅行日期前一个月完成。今天(7月30日)我可以预订门票,直到8月30日。明天我应该能够预订8月31日的门票。如何让它成为现实以及如何让mongodb自动为即将到来的日子创建一个集合?
我尝试过的事情:
我尝试在一段时间内将集合插入数据库。
i want to develop a travel booking website using MEAN stack development. Ticket booking can be done one month prior to the travel date. Today (30th July) i can book tickets till 30th august. Tomorrow i should be able to book tickets for 31st august. How to make it happen and how to make mongodb create a collection for upcoming days automatically ?
What I have tried:
I tried inserting collections into db for some set of days.
推荐答案
你不必担心创建那些收藏;如果您在不存在的集合中插入文档,MongoDB将自动创建一个集合。
但是如果由于您需要一些特殊设置而不够,请使用 db.createCollection [ ^ ]在确定它是否已经存在 [ ^ ]。
You don't have to worry about creating those collections; if you insert a document in a non-existing collection, MongoDB will automatically create a collection.
However if that's not sufficient because you need some special settings, use db.createCollection[^] to create the collection after figuring out if it already exists[^].
这篇关于如何根据日期自动将集合添加到mongodb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文