如何根据日期自动将集合添加到mongodb?

编程入门 行业动态 更新时间:2024-10-14 06:21:42
本文介绍了如何根据日期自动将集合添加到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?

本文发布于:2023-11-22 14:32:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1617823.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   mongodb

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!