Socket
Socket
Sign inDemoInstall

cozy-stack-client

Package Overview
Dependencies
3
Maintainers
1
Versions
319
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cozy-stack-client

## The constructor


Version published
Weekly downloads
1.6K
decreased by-27.16%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

46.5.0 (2024-04-03)

Features

  • Add a destroy method in ContactsCollection (4dd9c59)

Readme

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

Last updated on 03 Apr 2024

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc