mirror of
https://github.com/strapi/strapi.git
synced 2025-07-14 04:21:56 +00:00
34 lines
475 B
JavaScript
34 lines
475 B
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Module dependencies
|
|
*/
|
|
|
|
// Public node modules.
|
|
const _ = require('lodash');
|
|
|
|
/**
|
|
* JSON API utils for BookShelf
|
|
*/
|
|
|
|
module.exports = {
|
|
|
|
/**
|
|
* Find primary key
|
|
*/
|
|
|
|
getPK: function (type) {
|
|
return global[_.capitalize(type)].idAttribute || 'id';
|
|
},
|
|
|
|
/**
|
|
* Find primary key
|
|
*/
|
|
|
|
getCount: function (type) {
|
|
return strapi.bookshelf.collections[type].forge().count().then(function (count) {
|
|
return count;
|
|
});
|
|
}
|
|
};
|