@extropysk/payload
v1.4.0
Published
The Payload SDK gives you the ability to execute the same operations that are available through REST.
Readme
Payload SDK
The Payload SDK gives you the ability to execute the same operations that are available through REST.
Installation
npm install @extropysk/payload
Get Started
import { Config } from './payload-types'
import { Payload } from '@extropysk/payload'
const payload = new Payload<Config['collections']>({ baseUrl: 'http://localhost:3000' });Config
baseUrl- Payload CMS base url
Methods
All methods support parameters:
depth- automatically populates relationships and uploadslocale- retrieves document(s) in a specific locale
The find method supports the following additional parameters:
sort- sort by fieldwhere- pass a where query to constrain returned documentslimit- limit the returned documents to a certain numberpage- get a specific page of documents
find
const categories = await payload.find('categories',
{
sort: 'name'
}
)findByID
const category = await payload.findByID('categories', '507f191e810c19729de860ea',
{
depth: 0
}
)create
const category = await payload.create('categories',
{
name: 'shirts'
}
)update
const category = await payload.update('categories', '507f191e810c19729de860ea',
{
name: 'skirts'
}
)