用于存储用户位置历史的 MongoDB 模式 [英] MongoDB schema for storing user location history

查看:39
本文介绍了用于存储用户位置历史的 MongoDB 模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 MongoDB 来存储我的用户位置历史记录(当然是征得他们的同意).我看到以下三个选项:

I'd like to use MongoDB to store my users location history (with their consent, of course). I see the following three options:

  1. 为所有用户创建一个位置集合.每个文档都有一个 userId 字段和一个 time 字段,这两个字段都将被索引.此集合中的行数可能会超过 1 亿.
  2. 与用户创建一个集合,这些用户的位置为嵌入式数组.这使得搜索位置变得更加困难,因为 MongoDB 显然不支持返回嵌入文档的查询.
  3. 为每位用户创建一个包含他/她的位置历史记录的集合.我知道一个 MongoDB 实例有 24K 集合的限制,我认为目前这个限制是可以接受的.

如果您提供任何帮助我做出选择的反馈,我将不胜感激.

I'd appreciate any feedback which helps me making the choice.

谢谢和欢呼,乔治

推荐答案

正如在上面的评论中提到的,我选择了选项 1 并且在这一点上没有遗憾.感谢您的帮助.

As mentioned in the comments above, I've chosen option 1 and have no regrets at this point. Thanks for your help.

干杯,乔治

这篇关于用于存储用户位置历史的 MongoDB 模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆