Skip to Content

Collections

Retrieve functions

peekAll(collectionName)

Read all records from a local collection without triggering a request. Try it live.

ARM.peekAll('addresses')

peekRecord(collectionName, collectionRecordId)

Read a single record from a local collection without triggering a request. Try it live.

ARM.peekRecord('addresses', 2519858)

getCollection(collectionName)

Retrieve every record currently stored in a collection. Try it live.

ARM.getCollection('addresses')

getAlias(aliasName, fallbackRecords)

Retrieve the records stored under an alias from a previous request. fallbackRecords is optional. Try it live.

const addresses = ARM.getAlias('customerAddresses', []) ARM.findAll('addresses', { alias: 'customerAddresses' })

getRequestAlias(aliasName)

Retrieve the full returned object (isLoading, data, meta, etc.) for a previously aliased request. Try it live.

const addressesRequest = ARM.getRequestAlias('customerAddresses') ARM.findAll('addresses', { alias: 'customerAddresses' }) addressesRequest.data // the resolved records, once isLoading is false

Create

createRecord(collectionName, collectionRecord, collectionRecordRandomId)

Create a new record in a local collection. collectionRecord defaults to {}, collectionRecordRandomId defaults to true. Try it live.

// Set attributes after creation const newAddress = ARM.createRecord('addresses') newAddress.set('attributes.kind', 'school') newAddress.set('attributes.label', 'My school') // Or pass initial attributes directly const newAddress = ARM.createRecord('addresses', { attributes: { kind: 'school', label: 'My school' }, }) // Persist it to the server (POST /addresses) newAddress.save()

Remove

unloadRecord(collectionRecord)

Remove a record from the local collection only - does not call the server. Try it live.

const address = ARM.peekRecord('addresses', 2519858) ARM.unloadRecord(address)

clearCollection(collectionName)

Remove every record from a collection, along with any related aliases and request hashes. Try it live.

ARM.clearCollection('addresses')

Push

pushPayload(collectionName, collectionRecords)

Push raw records directly into a collection - useful for data fetched outside ARM’s own request functions. Try it live.

ARM.ajax({ method: 'get', url: 'addresses/2518368' }).then((response) => { ARM.pushPayload('addresses', response.data.data) })
Last updated on