Loopback : How to create embedded document or create object type

Here is your Contact model and if you want embed another model called as Address inside it then you need to put relations as embedsOne.
Please note that if you are using mongodb then embeds document will be part of parent document which mean all child documents will not be part of different collections which are linked, rather they will all be part of single parent doc.

“relations”: {
“address”: {
“type”: “embedsOne”,
“model”: “Address”,
“property”: “address”,
“options”: {
“validate”: true,
“forceId”: false
}

Now Contacts.json would look like this

{
“name”: “Contact”,
“base”: “PersistedModel”,
“idInjection”: true,
“options”: {
“validateUpsert”: true
},
“properties”: {
“id”: {
“type”: “string”,
“id”: true,
“defaultFn”: “uuid”
},
“name”: {
“type”: “string”,
“required”: true
},
“phone”: {
“type”: “string”,
“required”: true
},
“email”: {
“type”: “string”
},
“relationship”: {
“type”: “string”
}
},
“validations”: [],
“relations”: {
“address”: {
“type”: “embedsOne”,
“model”: “Address”,
“property”: “address”,
“options”: {
“validate”: true,
“forceId”: false
}
}
},
“acls”: [],
“methods”: {}
}

Please note that default id creator or sub document is “defaultFn”: “uuid” which will add id.

Advertisements

Mycarfax Mobile app to maintain your vehicle service records and more

Mycarfax mobile app which can help you maintain your vehicle by keeping track of service records, inspection records, registration records, repairs, current marked value etc.

web version: https://www.mycarfax.com/garage

Mobile app :https://itunes.apple.com/us/app/mycarfax-car-maintenance-and-service-history/id552472249?mt=8

It also provide you the current value of your vehicle. (if you want to sale it today).

It reminds you of dates when next service, inspection, registration etc is due.

It also notifies you for any recall on your model.

Its simple to sign up with facebook login and pull all records based on on VIN 🙂

I lost my convertible car since I skipped oil change, now I am using this app to keep track and get reminders. ITS FREE.

(Works in US region)

Mongodb – can’t login via -u root -p bitnami

Are you trying to login like this?

mongo admin --username root --password YOUR_PASSWORD

where YOUR_PASSWORD is the one you can see in your AWS system log:

Setting Bitnami application password to 'YOUR_PASSWORD'

If this doesn’t work, you can also try resetting MongoDB password:

http://wiki.bitnami.com/Components/mongoDB?highlight=mongo#How_to_reset_the_MongoDB_root_password.3f