简体   繁体   English

如何在不知道字段的情况下存储数据数组?

[英]how to store array of data without knowing the fields?

I am currently developing a Facebook application that calls upon the API and retrieve the user's info and display them on the front end. 我目前正在开发一个Facebook应用程序,该应用程序调用API并检索用户的信息并将其显示在前端。

However, since there are so many fields in the data. 但是,由于数据中有太多字段。 Could i actually store them into an array without knowing the fields using MongoDB? 我真的可以在不使用MongoDB知道字段的情况下将它们存储到数组中吗?

Data in MongoDB has a flexible schema. MongoDB中的数据具有灵活的架构。 Unlike SQL databases, where you must determine and declare a table's schema before inserting data, MongoDB's collections do not enforce document structure. 与SQL数据库不同,在SQL数据库中必须在插入数据之前确定并声明表的架构,而MongoDB的集合不会强制执行文档结构。

Read this articel: Data Modeling Introduction 阅读此文章: 数据建模简介

Instead of inserting data to array you can insert it as a new key-value pair to document. 除了将数据插入数组之外,您还可以将其作为文档的新键值对插入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM