/learn-mongo-api

CRUD and Relationships in MongoDB (Embedded and Document Referenced)

Primary LanguageJavaScript

Hasil dari Route Get dengan Relasi Embedded

Klik Branch embedded_relationships untuk melihat code

{
	"artistname" : "Reza Shahab",
	"band_members" :
	[
		{
			"singer_name" :  "l",
			"instruments" : ["Gitar", "Bass"]
		},
		{
			"singer_name" :  "Kevin A",
			"instruments" : ["Piano"]
		},
		{
			"singer_name" :  "Botak",
			"instruments" : ["Drum", "Klarinet"]
		}
	]
}

Hasil dari Route Get dengan Relasi Document Referenced

[
    {
        "_id": "5cd25fc1173df42af46ecd28",
        "id": "4",
        "artistname": "Rizal Hermawan",
        "band_members": [
            {
                "_id": "5cd13060173df42af46ecd1e",
                "singer_name": "GHI",
                "instrument": [
                    "Accordion",
                    "Jaw Harps",
                    "Keyboards"
                ],
                "artist_id": "4"
            },
            {
                "_id": "5cd146cf173df42af46ecd1f",
                "singer_name": "ABC",
                "instrument": [
                    "Banjo",
                    "Cello"
                ],
                "artist_id": "4"
            }
        ]
    },
    {
        "_id": "5cd2645c173df42af46ecd29",
        "id": "5",
        "artistname": "Suparman",
        "band_members": [
            {
                "_id": "5cd15068173df42af46ecd21",
                "singer_name": "Gita",
                "instrument": [
                    "OK"
                ],
                "artist_id": "5"
            }
        ]
    }
]