我正在使用 JavaScript(没有任何框架)创建一个仅限客户端的应用程序,将使用 MongoDB 来存储数据。我可以想到2 种方法来建模我的数据。
有人可以帮我理解哪个更合适。
方式#1
[{ title: "bucketList", id: 1, tasks: [{ title: "play soccer for world league", id: 1, done: false, comments: ["fifa 2014 is about to start", "need to go buy a Brazil T-shirt"] }, { title: "start a school", id: 2, done: true, comments: ["start with being a mentor"] }] }, { title: "to-do", id: 2, tasks: [{ title: "create a todo App", id: 1, done: false, comments: [] }, { title: "watch GOT", id: 2, done: false, comments: ["whitewalkers seems to be in no hurry"] }] }]
方式#2
[{ collection - title: "bucketList", collection - id: 1, title: "play soccer for world league", id: 1, done: false, comments: ["fifa 2014 is about to start", "need to go buy a Brazil T-shirt"] }, { collection - title: "bucketList", collection - id: 1, title: "start a school", id: 2, done: true, comments: ["start with being a mentor"] }, { collection - title: "to-do", collection - id: 2, title: "create a todo App", id: 1, done: false, comments: [] }, { collection - title: "to-do", collection - id: 2, title: "watch GOT", id: 2, done: false, comments: ["whitewalkers seems to be in no hurry"] }]