Deepu
Deepu

Reputation: 83

How to find loopback auto generated rest api names?

I was generated loopback.js framework auto generated rest api, I was trying to write acls for the rest api, that table contains multiple relations with other tables. I want to restrict every rest api call by using their names how do I find rest api names to write acls in loopback.js,

I mean if any rest api like "/users/{id}/requests" how to find this kind of rest api name. I am looking for any source or any suggestions.

Upvotes: 0

Views: 360

Answers (1)

Ivan Schwarz
Ivan Schwarz

Reputation: 814

From LoopBack documentation:

When two models have a relationship between them (see Creating model relations), LoopBack automatically creates a set of related model methods corresponding to the API routes defined for the relationship.

In the following list, modelName is the name of the related model and modelNamePlural is the plural form of the related model name.

belongsTo:

  • __get__relatedModelName

hasOne:

  • __create__relatedModelName
  • __get__relatedModelName
  • __update__relatedModelName
  • __destroy__relatedModelName

hasMany:

  • __count__relatedModelNamePlural
  • __create__relatedModelNamePlural
  • __delete__relatedModelNamePlural
  • __destroyById__relatedModelNamePlural
  • __findById__relatedModelNamePlural
  • __get__relatedModelNamePlural
  • __updateById__relatedModelNamePlural

hasManyThrough:

  • __count__relatedModelNamePlural
  • __create__relatedModelNamePlural
  • __delete__relatedModelNamePlural
  • __destroyById__relatedModelNamePlural
  • __exists__relatedModelNamePlural (through only)
  • __findById__relatedModelNamePlural
  • __get__relatedModelNamePlural
  • __link__relatedModelNamePlural (through only)
  • __updateById__relatedModelNamePlural
  • __unlink__relatedModelNamePlural (through only)

hasAndBelongsToMany:

  • __link__relatedModelNamePlural
  • __unlink__relatedModelNamePlural

Upvotes: 2

Related Questions