For example, I've created content type "Item" via admin panel. In /api/item/services/Item.js
I see code like
fetchAll: (params) => {
const convertedParams = strapi.utils.models.convertParams('item', params);
return Item
.find()
.where(convertedParams.where)
.sort(convertedParams.sort)
.skip(convertedParams.start)
.limit(convertedParams.limit)
.populate(_.keys(_.groupBy(_.reject(strapi.models.item.associations, {autoPopulate: false}), 'alias')).join(' '));
},
but Item
is not imported, so it is global.
Item
is created?Item
and strapi.models.item
?item
model: like service, strapi.models.item
or Item
? Thank you.
PS: if one of the authors of Strapi will read this, could you please tell why are you using global objects so heavily?
Global models are created on strapi-mongoose
or strapi-bookshelf
(depending of the database you use) It's in this node module we create instances of your models.
There is no difference between them Item
=== strapi.models.item
I think your middleware will have a dynamic logic so I recommend you to use strapi.models
and strapi.plugins[plugin].models
.
You are able to custom then global name of your models to be more easy to use https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#models
So the global name can change but not the path in the strapi
object.