简体   繁体   中英

can i create collection of collections in mongodb with nodejs

I want to store emails in mongodb, the email is in json format each email has an id and several emails can have the same id so i want to group the emails according to the id

expectation in mongodb

Emails(collection): id1(collection):email1,email2,email3, id2(collection):email1,email2,email3, id3(collection):email1,email2,email3, id4(collection):email1,email2,email3

An example shema

const { Schema, model } = require('mongoose');

const models = new Schema({
   email: {
     type: String,
     default: false,
     required: true
   }
});
module.exports = model('<collectionname>', models);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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