@sanity/document-window

2.0.9 • Public • Published

Sanity document window

Give it a query and it will keep that window up to date with changes.

Installing

npm install --save @sanity/document-window

Warning

API is still in flux and is likely to change in the near future. Use at your own risk.

Usage

const SanityClient = require('@sanity/client')
const DocumentWindow = require('@sanity/document-window')

const client = new SanityClient({
  projectId: 'your-project-id',
  dataset: 'some-dataset',
  useCdn: true
})

const query = new DocumentWindow.Query()
  .constraint('_type == $type && numSeats >= 2')
  .params({type: 'product'})
  .order([['numSeats', 'desc'], ['_updatedAt', 'desc']])
  .from(0)
  .to(20)

const articleWindow = new DocumentWindow({client, query})
articleWindow.on('data', docs => {
  console.log(docs)
})

License

MIT-licensed. See LICENSE.

Package Sidebar

Install

npm i @sanity/document-window

Weekly Downloads

1,122

Version

2.0.9

License

MIT

Unpacked Size

45.4 kB

Total Files

17

Last publish

Collaborators

  • armandocerna
  • daniel.malmer
  • jordanl17
  • tambet
  • jtpetty
  • drewsanity
  • refiito
  • sergeisarviro
  • ash
  • indrek.karner
  • cngonzalez-sanity
  • rdunk
  • rneatherway-sanity
  • ricokahler
  • pedro-sanity
  • jonabc
  • kenjonespizza
  • pauloborgesf
  • binoy14
  • simen.svale
  • svirs
  • josh_sanity_io
  • joneidejohnsen
  • nina.andal
  • rankers
  • snorreeb
  • mattcraig
  • vincentquigley
  • stipsan
  • michael-sanity
  • rubioz
  • tonina
  • ritasdias
  • simeonsanity
  • kmelve
  • bjoerge
  • rexxars
  • skogsmaskin
  • robinpyon
  • mariuslundgard
  • sanity-io
  • evenw
  • radhe_sanity
  • rbotten
  • judofyr
  • obliadp
  • dcilke
  • fredcarlsen
  • hermanw
  • sgulseth
  • atombender