-
-
Save vjefri/7e99c258f627cf41ebe8886f602ce0a5 to your computer and use it in GitHub Desktop.
Nodal TL:DR Seed Database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install -g nodal | |
nodal new todo-pgjson | |
cd todo-pgjson | |
nodal g:model Todo user_id:int tasks:json done:boolean | |
nodal g:controller --for Todos | |
nodal db:bootstrap | |
// add json data to seed.json | |
nodal db:seed | |
nodal db:bootstrap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// config/seed.json | |
{ | |
"development": { | |
"Todo": [ | |
{ | |
"user_id" : "1", | |
"done" : "false", | |
"tasks" : {"grapes":"7","bananas":"4","apples":"3"} | |
} | |
] | |
}, | |
"test": { | |
"Todo": [ | |
{ | |
"user_id" : "1", | |
"done" : "false", | |
"tasks" : {"grapes":"7","bananas":"4","apples":"3"} | |
} | |
] | |
}, | |
"production": {} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Request: | |
GET to /todos | |
Response: | |
{ | |
"meta": { | |
"total": 2, | |
"count": 2, | |
"offset": 0, | |
"error": null | |
}, | |
"data": [ | |
{ | |
"id": 1, | |
"user_id": 1, | |
"tasks": { | |
"apples": "3", | |
"grapes": "7", | |
"bananas": "4" | |
}, | |
"done": false, | |
"created_at": "2016-06-05T02:34:06.291Z", | |
"updated_at": "2016-06-05T02:34:06.291Z" | |
}, | |
{ | |
"id": 2, | |
"user_id": 1, | |
"tasks": { | |
"apples": "3", | |
"grapes": "7", | |
"bananas": "4" | |
}, | |
"done": false, | |
"created_at": "2016-06-05T02:34:09.730Z", | |
"updated_at": "2016-06-05T02:34:09.730Z" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment