2020-03-23 07:24:57 +00:00
|
|
|
module.exports = Self => {
|
2020-03-26 12:12:59 +00:00
|
|
|
Self.remoteMethodCtx('getCollection', {
|
2020-03-23 07:24:57 +00:00
|
|
|
description: 'Get pending collections from a worker',
|
2020-03-26 12:12:59 +00:00
|
|
|
accessType: 'READ',
|
2020-03-23 07:24:57 +00:00
|
|
|
returns: {
|
2021-09-06 14:35:31 +00:00
|
|
|
type: 'object',
|
2020-03-23 07:24:57 +00:00
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
2020-03-26 12:12:59 +00:00
|
|
|
path: `/getCollection`,
|
|
|
|
verb: 'GET'
|
2020-03-23 07:24:57 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-03-26 12:12:59 +00:00
|
|
|
Self.getCollection = async ctx => {
|
2020-03-23 07:24:57 +00:00
|
|
|
const userId = ctx.req.accessToken.userId;
|
|
|
|
const query = `CALL vn.collection_get(?)`;
|
|
|
|
const [result] = await Self.rawSql(query, [userId]);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
};
|