Skip to content

plusTTeam/loopback-content-range

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

loopback-content-range

Support react-admin for Loopback 3 by adding Content-Range header.

Installation

npm install --save loopback-content-range

Usage

Modify your server/component-config.json to include this module:

{
  "loopback-content-range": {
    "pattern": [
      "*.find"
    ],
    "relatedModels": true,
    "remoteModelRange": "after", // Default "before"
    "remoteRelationRange": "before" // Default "before"
  },
}

Options

pattern: Array of String

Method patterns that Content-Range header will be added.

Accepted patterns: See https://loopback.io/doc/en/lb3/Remote-hooks.html#wildcards.

Default value: [ "*.find" ], which auto added to find method of all models.

relatedModels: Boolean

Apply Content-Range to all related models.

defaultLimit: Integer

Set the default value when no limit parameter is passed on filter. If no defaultLimit value is defined it will assume the maxLimit value.

maxLimit: Integer

Set the maximum value of the limit paramater on filter.

remoteModelRange: String

Enables you to execute the function before or after a remote method is called by a client. Default 'before'.

remoteRelationRange: String

Enables you to execute the function before or after a remote method is called by a client. Default 'before'.

Tips

To fetch all records, do not define any values for defaultLimit and maxLimit.

Credits

Based on loopback3-xTotalCount and loopback-component-react-admin

About

Content-Range header for loopback 3

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%