Commit 34ee55587c2cd2313e39d516bc8267166cc2282d
1 parent
bce798864a
Exists in
master
add new model
Showing
5 changed files
with
75 additions
and
4 deletions
Show diff stats
bin/updateDb.js
1 | var path = require('path'); | 1 | var path = require('path'); |
2 | var app = require(path.resolve(__dirname, '../server/server')); | 2 | var app = require(path.resolve(__dirname, '../server/server')); |
3 | var dataSource = app.datasources.db; | 3 | var dataSource = app.datasources.db; |
4 | 4 | ||
5 | var models = ['User', 'AccessToken', 'ACL', 'RoleMapping', 'Role','user']; | 5 | var models = ['User', 'AccessToken', 'ACL', 'RoleMapping', 'Role','user','userProfile']; |
6 | 6 | ||
7 | dataSource.isActual(models, function(err, actual) { | 7 | dataSource.isActual(models, function(err, actual) { |
8 | if(err) throw err; | 8 | if(err) throw err; |
9 | if (!actual) { | 9 | if (!actual) { |
10 | dataSource.autoupdate(models, function(err, result) { | 10 | dataSource.autoupdate(models, function(err, result) { |
11 | if(err) throw err; | 11 | if(err) throw err; |
12 | console.log("Table is updated successfully in database."); | 12 | console.log("Table is updated successfully in database."); |
13 | console.log("err",err); | 13 | console.log("err",err); |
14 | dataSource.disconnect(); | 14 | dataSource.disconnect(); |
15 | }); | 15 | }); |
16 | } else { | 16 | } else { |
17 | console.log("Your table is already updated in database."); | 17 | console.log("Your table is already updated in database."); |
18 | dataSource.disconnect(); | 18 | dataSource.disconnect(); |
19 | } | 19 | } |
20 | }); | ||
20 | }); |
common/models/profile/userProfile.js
File was created | 1 | module.exports = function(userProfile) { | |
2 | |||
3 | }; |
common/models/profile/userProfile.json
File was created | 1 | { | |
2 | "name": "userProfile", | ||
3 | "base": "PersistedModel", | ||
4 | "idInjection": true, | ||
5 | "options": { | ||
6 | "validateUpsert": true | ||
7 | }, | ||
8 | "mixins": { | ||
9 | "TimeStamp": { | ||
10 | "required": true, | ||
11 | "validateUpsert": true, | ||
12 | "silenceWarnings": false | ||
13 | } | ||
14 | }, | ||
15 | "properties": { | ||
16 | "id": { | ||
17 | "type": "number", | ||
18 | "required": true, | ||
19 | "generated": true | ||
20 | }, | ||
21 | "formType": { | ||
22 | "type": "string", | ||
23 | "enum": ["formA", "formB", "formC", "formD"], | ||
24 | "required": false | ||
25 | }, | ||
26 | "name": { | ||
27 | "type": "string", | ||
28 | "required": false | ||
29 | }, | ||
30 | "work": { | ||
31 | "type": "string", | ||
32 | "required": false | ||
33 | }, | ||
34 | "monthlyIncome": { | ||
35 | "type": "number", | ||
36 | "required": false | ||
37 | }, | ||
38 | "city": { | ||
39 | "type": "string", | ||
40 | "required": false | ||
41 | }, | ||
42 | "email": { | ||
43 | "type": "stirng", | ||
44 | "required": false | ||
45 | }, | ||
46 | "dob": { | ||
47 | "type": "date", | ||
48 | "required": false | ||
49 | }, | ||
50 | "phone": { | ||
51 | "type": "number", | ||
52 | "required": false | ||
53 | } | ||
54 | }, | ||
55 | |||
56 | "validations": [], | ||
57 | "relations": { | ||
58 | }, | ||
59 | "acls": [ | ||
60 | |||
61 | ], | ||
62 | "methods": {} | ||
63 | } |
server/config.json
1 | { | 1 | { |
2 | "restApiRoot": "/api", | 2 | "restApiRoot": "/api", |
3 | "host": "0.0.0.0", | 3 | "host": "0.0.0.0", |
4 | "port": 3002, | 4 | "port": 3004, |
5 | "remoting": { | 5 | "remoting": { |
6 | "rest": { | 6 | "rest": { |
7 | "enableHttpContext": false | 7 | "enableHttpContext": false |
8 | }, | 8 | }, |
9 | "rest": { | 9 | "rest": { |
10 | "handleErrors": false, | 10 | "handleErrors": false, |
11 | "normalizeHttpPath": false, | 11 | "normalizeHttpPath": false, |
12 | "xml": false | 12 | "xml": false |
13 | }, | 13 | }, |
14 | "json": { | 14 | "json": { |
15 | "strict": false, | 15 | "strict": false, |
16 | "limit": "100kb" | 16 | "limit": "100kb" |
17 | }, | 17 | }, |
18 | "urlencoded": { | 18 | "urlencoded": { |
19 | "extended": true, | 19 | "extended": true, |
20 | "limit": "100kb" | 20 | "limit": "100kb" |
21 | }, | 21 | }, |
22 | "cors": false | 22 | "cors": false |
23 | }, | 23 | }, |
24 | "legacyExplorer": false, | 24 | "legacyExplorer": false, |
25 | "logoutSessionsOnSensitiveChanges": true | 25 | "logoutSessionsOnSensitiveChanges": true |
26 | } | 26 | } |
27 | 27 |
server/model-config.json
1 | { | 1 | { |
2 | "_meta": { | 2 | "_meta": { |
3 | "sources": [ | 3 | "sources": [ |
4 | "loopback/common/models", | 4 | "loopback/common/models", |
5 | "loopback/server/models", | 5 | "loopback/server/models", |
6 | "../common/models", | 6 | "../common/models", |
7 | "./models" | 7 | "./models", |
8 | "../common/models/profile" | ||
8 | ], | 9 | ], |
9 | "mixins": [ | 10 | "mixins": [ |
10 | "loopback/common/mixins", | 11 | "loopback/common/mixins", |
11 | "loopback/server/mixins", | 12 | "loopback/server/mixins", |
12 | "../common/mixins", | 13 | "../common/mixins", |
13 | "./mixins" | 14 | "./mixins" |
14 | ] | 15 | ] |
15 | }, | 16 | }, |
16 | "User": { | 17 | "User": { |
17 | "dataSource": "db", | 18 | "dataSource": "db", |
18 | "public": false | 19 | "public": false |
19 | }, | 20 | }, |
20 | "AccessToken": { | 21 | "AccessToken": { |
21 | "dataSource": "db", | 22 | "dataSource": "db", |
22 | "public": false | 23 | "public": false |
23 | }, | 24 | }, |
24 | "ACL": { | 25 | "ACL": { |
25 | "dataSource": "db", | 26 | "dataSource": "db", |
26 | "public": false | 27 | "public": false |
27 | }, | 28 | }, |
28 | "RoleMapping": { | 29 | "RoleMapping": { |
29 | "dataSource": "db", | 30 | "dataSource": "db", |
30 | "public": false, | 31 | "public": false, |
31 | "options": { | 32 | "options": { |
32 | "strictObjectIDCoercion": true | 33 | "strictObjectIDCoercion": true |
33 | } | 34 | } |
34 | }, | 35 | }, |
35 | "Role": { | 36 | "Role": { |
36 | "dataSource": "db", | 37 | "dataSource": "db", |
37 | "public": false | 38 | "public": false |
38 | }, | 39 | }, |
39 | "user": { | 40 | "user": { |
40 | "dataSource": "db", | 41 | "dataSource": "db", |
41 | "public": true | 42 | "public": true |
42 | }, | 43 | }, |
43 | "Email": { | 44 | "Email": { |
44 | "dataSource": "email" | 45 | "dataSource": "email" |
46 | }, | ||
47 | "userProfile": { | ||
48 | "dataSource": "db", | ||
49 | "public": true | ||
45 | } | 50 | } |
46 | } | 51 | } |