Skip to content

Commit

Permalink
wokrs
Browse files Browse the repository at this point in the history
  • Loading branch information
atherdon committed Feb 18, 2018
1 parent f069b6e commit ac20f9f
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 13 deletions.
28 changes: 28 additions & 0 deletions bin/002-automigrate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';

var path = require('path');

let app = require(path.resolve(__dirname, '../server/server'));
var database = app.datasources.searchDS;


var lbTables = [
'Attribute',
'Department',
'Ingredient',
'Menu',
'Recipe'
];

//creating loopback necessary tables if no exists
database.automigrate(lbTables, function(err) {
if (err) throw err;

console.log( 'Loopback tables [' + lbTables.toString() + '] created in ' + database.adapter.name );
database.disconnect();

// process.on('exit', function(code) {
// return console.log(`Automigrate is competed`);
// });
// process.exit(22);
});
Empty file removed bin/automigrate.js
Empty file.
Empty file removed models/attributes.json
Empty file.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"start": "node .",
"posttest": "npm run lint && nsp check",
"watch": "nodemon server/server.js",
"migrate-recipes": "node bin/recipes/automigrate.js",

"migrate": "node bin/002-automigrate.js",

"import": "node bin/recipes/import.js",
"grocery": "node bin/grocery/import.js",
"search": "node bin/search/import.js",
Expand Down
2 changes: 1 addition & 1 deletion server/datasources.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"recipeDS": {
"searchDS": {
"url": "mongodb://heroku_ghbnqks1:eb8kogbcofqvkh13d6ccep825l@ds139994.mlab.com:39994/heroku_ghbnqks1",
"name": "searchDS",
"connector": "loopback-connector-mongodb"
Expand Down
18 changes: 9 additions & 9 deletions server/model-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@
"./mixins"
]
},
"departments": {
"Department": {
"dataSource": "searchDS",
"public": true
},
"groceries": {
"Ingredient": {
"dataSource": "searchDS",
"public": true
},
"ingredients": {
"Menu": {
"dataSource": "searchDS",
"public": true
},
"menus": {
"Recipe": {
"dataSource": "searchDS",
"public": true
},
"recipes": {
"User": {
"dataSource": "searchDS",
"public": true
"public": false
},
"weekly-menu": {
"ACL": {
"dataSource": "searchDS",
"public": true
"public": false
},
"attributes": {
"Attribute": {
"dataSource": "searchDS",
"public": true
}
Expand Down
7 changes: 5 additions & 2 deletions models/attributes.js → server/models/attribute.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@


// it's the place were we'll store all stuff.

// And i want to have a remote methods and things, that i can easily call 'diets' and get stuff related only for ingredients

// and then i'll came to a simple method where i only include or exclude ids
'use strict';

module.exports = function(Attribute) {

};
24 changes: 24 additions & 0 deletions server/models/attribute.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Attribute",
"plural": "attribute",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"name": {
"type": "string",
"required": true
},

"type": {
"type": "string",
"required": true
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ac20f9f

Please sign in to comment.