2017-03-20 22:08:49 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A set of functions called "actions" for `ContentManager`
|
|
|
|
*/
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
|
|
|
models: async(ctx) => {
|
|
|
|
ctx.body = strapi.models;
|
|
|
|
},
|
|
|
|
|
|
|
|
find: async(ctx) => {
|
|
|
|
const model = ctx.params.model;
|
|
|
|
|
2017-04-11 11:34:59 +02:00
|
|
|
const {
|
|
|
|
limit = 10,
|
|
|
|
skip = 0,
|
2017-04-11 13:44:47 +02:00
|
|
|
sort = 'id'
|
2017-04-11 11:34:59 +02:00
|
|
|
} = ctx.request.query;
|
|
|
|
|
2017-03-20 22:08:49 +01:00
|
|
|
const entries = await User
|
2017-04-11 11:34:59 +02:00
|
|
|
.find()
|
|
|
|
.limit(limit)
|
2017-04-11 13:44:47 +02:00
|
|
|
.sort(sort)
|
2017-04-11 11:34:59 +02:00
|
|
|
.limit(skip);
|
2017-03-20 22:08:49 +01:00
|
|
|
|
|
|
|
ctx.body = entries;
|
|
|
|
},
|
|
|
|
|
2017-04-11 11:34:59 +02:00
|
|
|
count: async(ctx) => {
|
|
|
|
const model = ctx.params.model;
|
|
|
|
|
|
|
|
const count = await User
|
|
|
|
.count();
|
|
|
|
|
|
|
|
ctx.body = {
|
|
|
|
count: Number(count)
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2017-03-20 22:08:49 +01:00
|
|
|
findOne: async(ctx) => {
|
|
|
|
const model = ctx.params.model;
|
|
|
|
const id = ctx.params.id;
|
|
|
|
|
|
|
|
const entries = await User
|
|
|
|
.find({
|
2017-04-11 11:34:59 +02:00
|
|
|
id
|
2017-03-20 22:08:49 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
ctx.body = entries;
|
|
|
|
}
|
|
|
|
};
|