author | ymh <ymh.work@gmail.com> |
Thu, 02 Jun 2016 18:24:19 +0200 | |
changeset 168 | 17f10b56c079 |
parent 164 | 5f1e1cc17e8a |
permissions | -rw-r--r-- |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
import ENV from 'app-client/config/environment'; |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
import _ from 'lodash/lodash'; |
127
5cd8c3065c38
extract common functionalities to common module. First application to lexvo name resolving
ymh <ymh.work@gmail.com>
parents:
126
diff
changeset
|
3 |
import * as constants from 'corpus-common-addon/utils/constants'; |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
|
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
export default function() { |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
7 |
// These comments are here to help you get started. Feel free to delete them. |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
9 |
/* |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
10 |
Config (with defaults). |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
12 |
Note: these only affect routes defined *after* them! |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
13 |
*/ |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
14 |
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
15 |
// this.namespace = ''; // make this `api`, for example, if your API is namespaced |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
16 |
this.namespace = ENV.baseURL.replace(/\/$/,'')+'/api/v1'; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
17 |
// this.timing = 400; // delay for each request, automatically set to 0 during testing |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
19 |
this.get('/documents'); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
20 |
this.get('/documents/:id', function(db, request) { |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
21 |
var docId = decodeURIComponent(request.params.id); |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
23 |
return { |
168
17f10b56c079
improve document model and propagate changes. This include the change of document fixtures to better reflect what the api is effectively returning
ymh <ymh.work@gmail.com>
parents:
164
diff
changeset
|
24 |
'document': db.details_documents.find(docId) |
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
25 |
}; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
26 |
}); |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
|
164
5f1e1cc17e8a
add mirage fixtures and api path for testing in app client
ymh <ymh.work@gmail.com>
parents:
160
diff
changeset
|
28 |
this.get('/documents/:id/transcript', function(db, request) { |
5f1e1cc17e8a
add mirage fixtures and api path for testing in app client
ymh <ymh.work@gmail.com>
parents:
160
diff
changeset
|
29 |
var docId = decodeURIComponent(request.params.id); |
5f1e1cc17e8a
add mirage fixtures and api path for testing in app client
ymh <ymh.work@gmail.com>
parents:
160
diff
changeset
|
30 |
|
5f1e1cc17e8a
add mirage fixtures and api path for testing in app client
ymh <ymh.work@gmail.com>
parents:
160
diff
changeset
|
31 |
return db.transcripts.find(docId).transcript; |
5f1e1cc17e8a
add mirage fixtures and api path for testing in app client
ymh <ymh.work@gmail.com>
parents:
160
diff
changeset
|
32 |
}); |
5f1e1cc17e8a
add mirage fixtures and api path for testing in app client
ymh <ymh.work@gmail.com>
parents:
160
diff
changeset
|
33 |
|
5f1e1cc17e8a
add mirage fixtures and api path for testing in app client
ymh <ymh.work@gmail.com>
parents:
160
diff
changeset
|
34 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
35 |
this.get('/languages', function(db) { |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
36 |
var res = {}; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
37 |
_.each(db.languages, function(lang) { |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
38 |
res[lang.id] = lang.count; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
39 |
}); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
40 |
return res; |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
41 |
}); |
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
42 |
|
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
43 |
this.get('/themes', function(db) { |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
44 |
var res = {}; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
45 |
_.each(db.themes, function(theme) { |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
46 |
res[theme.id] = {'label': theme.label, 'count': theme.count}; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
47 |
}); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
48 |
return res; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
49 |
}); |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
50 |
|
160
c77f06ff3e54
add discourse controler + fixtures
ymh <ymh.work@gmail.com>
parents:
158
diff
changeset
|
51 |
this.get('/discourses', function(db) { |
c77f06ff3e54
add discourse controler + fixtures
ymh <ymh.work@gmail.com>
parents:
158
diff
changeset
|
52 |
var res = {}; |
c77f06ff3e54
add discourse controler + fixtures
ymh <ymh.work@gmail.com>
parents:
158
diff
changeset
|
53 |
_.each(db.discourses, function(discourse) { |
c77f06ff3e54
add discourse controler + fixtures
ymh <ymh.work@gmail.com>
parents:
158
diff
changeset
|
54 |
res[discourse.id] = {'label': discourse.label, 'count': discourse.count}; |
c77f06ff3e54
add discourse controler + fixtures
ymh <ymh.work@gmail.com>
parents:
158
diff
changeset
|
55 |
}); |
c77f06ff3e54
add discourse controler + fixtures
ymh <ymh.work@gmail.com>
parents:
158
diff
changeset
|
56 |
return res; |
c77f06ff3e54
add discourse controler + fixtures
ymh <ymh.work@gmail.com>
parents:
158
diff
changeset
|
57 |
}); |
c77f06ff3e54
add discourse controler + fixtures
ymh <ymh.work@gmail.com>
parents:
158
diff
changeset
|
58 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
59 |
this.get('/lexvo/:ids', function(db, request) { |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
60 |
var langIds = decodeURIComponent(request.params.ids); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
61 |
var resMap = _.reduce(langIds.split(','), function(res, id) { |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
62 |
var fullId = id; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
63 |
if(!_.startsWith(fullId, constants.LEXVO_BASE_URL)) { |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
64 |
fullId = constants.LEXVO_BASE_URL + id; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
65 |
} |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
66 |
var lexvoRes = db.lexvo.find(fullId); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
67 |
res[id] = lexvoRes?lexvoRes.name:null; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
68 |
return res; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
69 |
}, {}); |
127
5cd8c3065c38
extract common functionalities to common module. First application to lexvo name resolving
ymh <ymh.work@gmail.com>
parents:
126
diff
changeset
|
70 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
71 |
return { |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
72 |
'lexvoids': resMap |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
73 |
}; |
127
5cd8c3065c38
extract common functionalities to common module. First application to lexvo name resolving
ymh <ymh.work@gmail.com>
parents:
126
diff
changeset
|
74 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
75 |
}); |
127
5cd8c3065c38
extract common functionalities to common module. First application to lexvo name resolving
ymh <ymh.work@gmail.com>
parents:
126
diff
changeset
|
76 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
77 |
this.get('/bnf/:ids', function(db, request) { |
134
c06d08c8a1b8
add bnf resolver in common addon + applications
ymh <ymh.work@gmail.com>
parents:
127
diff
changeset
|
78 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
79 |
var bnfIds = decodeURIComponent(request.params.ids); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
80 |
var resMap = _.reduce(bnfIds.split(','), function(res, id) { |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
81 |
var fullId = id; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
82 |
if(_.startsWith(fullId, constants.BNF_BASE_URL)) { |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
83 |
fullId = fullId.slice(constants.BNF_BASE_URL.length); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
84 |
} else if (_.startsWith(fullId, constants.BNF_ARK_BASE_URL)) { |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
85 |
fullId = fullId.slice(constants.BNF_ARK_BASE_URL.length); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
86 |
} else if (!_.startsWith(fullId, constants.BNF_ARK_BASE_ID)) { |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
87 |
fullId = constants.BNF_ARK_BASE_ID + fullId; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
88 |
} |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
89 |
var bnfRes = db.lexvo.find(fullId); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
90 |
res[fullId] = bnfRes?bnfRes.label:null; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
91 |
return res; |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
92 |
}, {}); |
134
c06d08c8a1b8
add bnf resolver in common addon + applications
ymh <ymh.work@gmail.com>
parents:
127
diff
changeset
|
93 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
94 |
return { |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
95 |
'bnfids': resMap |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
96 |
}; |
134
c06d08c8a1b8
add bnf resolver in common addon + applications
ymh <ymh.work@gmail.com>
parents:
127
diff
changeset
|
97 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
98 |
}); |
134
c06d08c8a1b8
add bnf resolver in common addon + applications
ymh <ymh.work@gmail.com>
parents:
127
diff
changeset
|
99 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
100 |
/* |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
101 |
Route shorthand cheatsheet |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
102 |
*/ |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
103 |
/* |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
104 |
GET shorthands |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
105 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
106 |
// Collections |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
107 |
this.get('/contacts'); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
108 |
this.get('/contacts', 'users'); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
109 |
this.get('/contacts', ['contacts', 'addresses']); |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
110 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
111 |
// Single objects |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
112 |
this.get('/contacts/:id'); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
113 |
this.get('/contacts/:id', 'user'); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
114 |
this.get('/contacts/:id', ['contact', 'addresses']); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
115 |
*/ |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
116 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
117 |
/* |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
118 |
POST shorthands |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
119 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
120 |
this.post('/contacts'); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
121 |
this.post('/contacts', 'user'); // specify the type of resource to be created |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
122 |
*/ |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
123 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
124 |
/* |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
125 |
PUT shorthands |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
126 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
127 |
this.put('/contacts/:id'); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
128 |
this.put('/contacts/:id', 'user'); // specify the type of resource to be updated |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
129 |
*/ |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
130 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
131 |
/* |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
132 |
DELETE shorthands |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
133 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
134 |
this.del('/contacts/:id'); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
135 |
this.del('/contacts/:id', 'user'); // specify the type of resource to be deleted |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
136 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
137 |
// Single object + related resources. Make sure parent resource is first. |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
138 |
this.del('/contacts/:id', ['contact', 'addresses']); |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
139 |
*/ |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
140 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
141 |
/* |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
142 |
Function fallback. Manipulate data in the db via |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
143 |
|
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
144 |
- db.{collection} |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
145 |
- db.{collection}.find(id) |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
146 |
- db.{collection}.where(query) |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
147 |
- db.{collection}.update(target, attrs) |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
148 |
- db.{collection}.remove(target) |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
149 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
150 |
// Example: return a single object with related models |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
151 |
this.get('/contacts/:id', function(db, request) { |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
152 |
var contactId = +request.params.id; |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
153 |
|
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
154 |
return { |
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
155 |
contact: db.contacts.find(contactId), |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
156 |
addresses: db.addresses.where({contact_id: contactId}) |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
157 |
}; |
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
158 |
}); |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
159 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
160 |
*/ |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
161 |
} |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
162 |
|
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
163 |
/* |
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
164 |
You can optionally export a config that is only loaded during tests |
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
165 |
export function testConfig() { |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
166 |
|
158
366509ae2f37
Add controller for themes count + upgrade ember for app-client
ymh <ymh.work@gmail.com>
parents:
134
diff
changeset
|
167 |
} |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
168 |
*/ |