-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdataaccess.base.js
392 lines (391 loc) · 11.6 KB
/
dataaccess.base.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
// if next object is set, pass it through to next object
// otherwise end chain
module.exports = {
next: null,
/*
* users
*/
addUser: function(username, password, callback) {
if (this.next) {
this.next.addUser(username,password,callback);
} else {
console.log('dataaccess.base.js::addUser - write me!');
callback(null, null);
}
},
setUser: function(iuser, ts, callback) {
if (this.next) {
this.next.setUser(iuser, ts, callback);
} else {
console.log('dataaccess.base.js::setUser - write me!');
callback(null, null);
}
},
delUser: function(userid, callback) {
if (this.next) {
this.next.delUser(userid, callback);
} else {
console.log('dataaccess.base.js::delUser - write me!');
callback(null, null);
}
},
getUserID: function(username, callback) {
if (this.next) {
this.next.getUserID(username, callback);
} else {
console.log('dataaccess.base.js::getUserID - write me!');
callback(null, null);
}
},
// callback is user,err,meta
getUser: function(userid, callback) {
if (this.next) {
this.next.getUser(userid, callback);
} else {
console.log('dataaccess.base.js::getUser - write me!');
callback(null, null);
}
},
/*
* local user token
*/
// should we really pass token in? it's cleaner separation if we do
// even though this is the only implemention of the abstraction
addAPIUserToken: function(userid, client_id, scopes, token, callback) {
if (this.next) {
this.next.addAPIUserToken(userid, client_id, scopes, token, callback);
} else {
console.log('dataaccess.base.js::addAPIUserToken - write me!');
callback(null, null);
}
},
delAPIUserToken: function(token, callback) {
if (this.next) {
this.next.delAPIUserToken(token, callback);
} else {
console.log('dataaccess.base.js::delAPIUserToken - write me!');
callback(null, null);
}
},
getAPIUserToken: function(token, callback) {
if (this.next) {
this.next.getAPIUserToken(token, callback);
} else {
console.log('dataaccess.base.js::getAPIUserToken - write me!');
callback(null, null);
}
},
/*
* user upstream tokens
*/
setUpstreamUserToken: function(userid, token, scopes, upstreamUserId, callback) {
if (this.next) {
this.next.setUpstreamUserToken(userid, token, scopes, upstreamUserId, callback);
} else {
console.log('dataaccess.base.js::setUpstreamUserToken - write me!');
callback(null, null);
}
},
/*
* local clients
*/
addLocalClient: function(userid, callback) {
if (this.next) {
this.next.addLocalClient(userid, callback);
} else {
console.log('dataaccess.base.js::addLocalClient - write me!');
callback(null, null);
}
},
getLocalClient: function(client_id, callback) {
if (this.next) {
this.next.getLocalClient(client_id, callback);
} else {
console.log('dataaccess.base.js::getLocalClient - write me!');
callback(null, null);
}
},
delLocalClient: function(client_id,callback) {
if (this.next) {
this.next.delLocalClient(client_id, callback);
} else {
console.log('dataaccess.base.js::delLocalClient - write me!');
callback(null, null);
}
},
/*
* clients
*/
addSource: function(client_id, name, link, callback) {
if (this.next) {
this.next.addSource(client_id, name, link, callback);
} else {
console.log('dataaccess.base.js::addSource - write me!');
callback(null, null);
}
},
getClient: function(client_id, callback) {
if (this.next) {
this.next.getClient(client_id, callback);
} else {
console.log('dataaccess.base.js::getClient - write me!');
callback(null, null);
}
},
setSource: function(source, callback) {
if (this.next) {
this.next.setSource(source, callback);
} else {
console.log('dataaccess.base.js::setSource - write me!');
callback(null, null);
}
},
/* client (app) tokens */
addAPIAppToken: function(client_id, token, request) {
console.log('dataaccess.base.js::addAPIAppToken - write me!');
},
delAPIAppToken: function(client_id, token) {
console.log('dataaccess.base.js::delAPIAppToken - write me!');
},
getAPIAppToken: function(client_id, token) {
console.log('dataaccess.base.js::getAPIAppToken - write me!');
},
/* client upstream token */
addUpstreamClientToken: function(token, scopes) {
console.log('dataaccess.base.js::addUpstreamClientToken - write me!');
},
delUpstreamClientToken: function(token) {
console.log('dataaccess.base.js::delUpstreamClientToken - write me!');
},
getUpstreamClientToken: function() {
console.log('dataaccess.base.js::getUpstreamClientToken - write me!');
},
/** user stream */
/** app stream */
/**
* posts
*/
addPost: function(ipost, callback) {
if (this.next) {
this.next.addPost(ipost, callback);
} else {
console.log('dataaccess.base.js::addPost - write me!');
callback(null, null);
}
},
setPost: function(ipost, callback) {
if (this.next) {
this.next.setPost(ipost, callback);
} else {
console.log('dataaccess.base.js::setPost - write me!');
callback(null, null);
}
},
getPost: function(id, callback) {
if (this.next) {
this.next.getPost(id, callback);
} else {
console.log('dataaccess.base.js::getPost - write me!');
callback(null, null);
}
},
getUserPosts: function(userid, params, callback) {
if (this.next) {
this.next.getUserPosts(userid, params, callback);
} else {
console.log('dataaccess.base.js::getUserPosts - write me!');
callback(null, null);
}
},
getGlobal: function(params, callback) {
if (this.next) {
this.next.getGlobal(params, callback);
} else {
console.log('dataaccess.base.js::getGlobal - write me!');
callback(null, null, null);
}
},
getExplore: function(params, callback) {
if (this.next) {
this.next.getExplore(params, callback);
} else {
console.log('dataaccess.base.js::getExplore - write me!');
callback(null, null, null);
}
},
/** channels */
setChannel: function (chnl, ts, callback) {
if (this.next) {
this.next.setChannel(chnl, ts, callback);
} else {
console.log('dataaccess.base.js::setChannel - write me!');
callback(null, null);
}
},
getChannel: function(id, callback) {
if (this.next) {
this.next.getChannel(id, callback);
} else {
console.log('dataaccess.base.js::getChannel - write me!');
callback(null, null);
}
},
/** messages */
setMessage: function (msg, callback) {
if (this.next) {
this.next.setMessage(msg, callback);
} else {
console.log('dataaccess.base.js::setMessage - write me!');
callback(null, null);
}
},
getMessage: function(id, callback) {
if (this.next) {
this.next.getMessage(id, callback);
} else {
console.log('dataaccess.base.js::getMessage - write me!');
callback(null, null);
}
},
getChannelMessages: function(channelid, params, callback) {
if (this.next) {
this.next.getChannelMessages(channelid, params, callback);
} else {
console.log('dataaccess.base.js::getChannelMessages - write me!');
callback(null, null);
}
},
/** subscription */
/*
channelid: { type: Number, index: true },
userid: { type: Number, index: true },
created_at: { type: Date, index: true },
active: { type: Boolean, index: true },
last_updated: { type: Date },
*/
setSubscription: function (chnlid, userid, del, ts, callback) {
if (this.next) {
this.next.setSubscription(chnlid, userid, del, ts, callback);
} else {
console.log('dataaccess.base.js::setSubscription - write me!');
callback(null, null);
}
},
getUserSubscriptions: function(userid, params, callback) {
if (this.next) {
this.next.getUserSubscriptions(userid, params, callback);
} else {
console.log('dataaccess.base.js::getUserSubscriptions - write me!');
callback(null, null);
}
},
getChannelSubscriptions: function(channelid, params, callback) {
if (this.next) {
this.next.getChannelSubscriptions(channelid, params, callback);
} else {
console.log('dataaccess.base.js::getChannelSubscriptions - write me!');
callback(null, null);
}
},
/** files */
/** entities */
// should this model more closely follow the annotation model?
// not really because entities are immutable (on posts not users)
extractEntities: function(type, id, entities, entitytype, callback) {
if (this.next) {
this.next.extractEntities(type, id, entities, entitytype, callback);
} else {
console.log('dataaccess.base.js::extractEntities - write me!');
callback(null, null);
}
},
getEntities: function(type, id, callback) {
if (this.next) {
this.next.getEntities(type, id, callback);
} else {
console.log('dataaccess.base.js::getEntities - write me!');
callback(null, null);
}
},
// more like getHashtagEntities
getHashtagEntities: function(hashtag, params, callback) {
if (this.next) {
this.next.getHashtagEntities(hashtag, params, callback);
} else {
console.log('dataaccess.base.js::getHashtagEntities - write me!');
callback(null, null);
}
},
/**
* Annotations
*/
addAnnotation: function(idtype, id, type, value, callback) {
if (this.next) {
this.next.addAnnotation(idtype, id, type, value, callback);
} else {
console.log('dataaccess.base.js::addAnnotation - write me!');
callback(null, null);
}
},
clearAnnotations: function(idtype,id,callback) {
if (this.next) {
this.next.clearAnnotations(idtype, id, callback);
} else {
console.log('dataaccess.base.js::clearAnnotations - write me!');
callback(null, null);
}
},
getAnnotations: function(idtype, id, callback) {
if (this.next) {
this.next.getAnnotations(idtype, id, callback);
} else {
console.log('dataaccess.base.js::getAnnotations - write me!');
callback(null, null);
}
},
/** follow */
setFollow: function (srcid, trgid, id, del, ts, callback) {
if (this.next) {
this.next.setFollow(srcid, trgid, id, del, ts, callback);
} else {
console.log('dataaccess.base.js::setFollow - write me!');
callback(null, null);
}
},
getFollows: function(userid, params, callback) {
if (this.next) {
this.next.getFollows(userid, params, callback);
} else {
console.log('dataaccess.base.js::getFollows - write me!');
callback(null, null);
}
},
/** Star/Interactions */
setInteraction: function(userid, postid, type, metaid, deleted, ts, callback) {
if (this.next) {
this.next.setInteraction(userid, postid, type, metaid, deleted, ts, callback);
} else {
console.log('dataaccess.base.js::setInteraction - write me!');
callback(null, null);
}
},
// getUserInteractions, remember reposts are stored here too
// if we're going to use one table, let's keep the code advantages from that
// getUserStarPosts
getInteractions: function(type, userid, params, callback) {
if (this.next) {
this.next.getInteractions(type, userid, params, callback);
} else {
console.log('dataaccess.base.js::getInteractions - write me!');
callback(null, null);
}
},
getOEmbed: function(url, callback) {
if (this.next) {
this.next.getOEmbed(url, callback);
} else {
console.log('dataaccess.base.js::getOEmbed - write me!');
callback(null, null);
}
}
}