Unable to use email as name of database in mongodb

Viewed 33

if I do mongoose.connect('whatever/email(as DB name)'), it throws errors. Is there any way to do it? I want to make a separate DB for each email.

1 Answers

You can do as below.

Have a users meta collection

{
  email:"a@action.com",
  uniqueId: 12
}

Use this uniqueId as collection name to store details.

But this would require two calls every time - one to find user collection and another one on querying the respective collection.

Related