You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cozy-stack-client

Package Overview
Dependencies
Maintainers
1
Versions
353
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cozy-stack-client

60.0.0
latest
Source
npmnpm
Version published
Weekly downloads
5.1K
-42.92%
Maintainers
1
Weekly downloads
 
Created
Source

cozy-stack-client

The constructor

const client = new CozyStackClient(options)

Options

  • uri: The Cozy instance URI ;
  • token: The token given by the stack.

Collections

A collection is the set of all documents of a same doctype.

Selecting a collection is done by calling the collection() method, passing it the doctype:

const todos = client.collection('io.cozy.todos')

Listing all documents

const allTodos = await todos.all()
console.log(allTodos.data)

Pagination

By default, the stack limits the number of query results to 100 documents. If the limit causes some documents not to be returned, the response will have a next: true property.

By using the skip and limit options you can build your own pagination:

const firstPage = await todos.all({ limit: 100 })
if (firstPage.next) {
  const secondPage = await todos.all({ skip: 100, limit: 100 })
}

You can also use the meta.count property to know the total count of documents.

const allTodos = await todos.all()
console.log(`There are ${allTodos.meta.count} todos.`)

Finding documents

const doneTodos = await todos.find({ done: true })
console.log(allTodos.data)

FAQs

Package last updated on 17 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts