Unable to create schema of table in mongo database

N Sharma

I am creating a database in mongodb. I have this sample JSON format

{
    first_name: "John",
    last_name: "Doe",
    memberships: ["mem1", "mem2"],
    address: {
        street: "4 main st",
        city: "Boston"
    },
    contacts: [
        {
            name: "Brad",
            relationship: "friend"
        }
    ]
}

I have created a database and collection "user". I want to define a schema of this collection as like above JSON.

I am using mongodb compass tool https://www.mongodb.com/products/compass to create database, collection, schema, managing etc, I am applying this JSON in input box which is left of apply button, so on clicking on apply button it does not create a schema.

Does anyone know what is the way to create a schema of collection using this tool ?

enter image description here

N Sharma

I see that mongodb is schema less database. You can insert any type of document in a single collection, but you should avoid to insert complete application data in a single collection.

You should create multiple collection to see fast execution of find queries.

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related