This package has been deprecated

Author message:

This package is deprecated

@sanity/gradient-client

0.1.4 • Public • Published

gradient-client

Javascript client for the Gradient document store. Works in both Node.js and modern browsers.

Installation

npm install @sanity/gradient-client

Usage

const gradient = require('@sanity/gradient-client')
const client = gradient({
  url: 'https://gradient.url:56200',
  dataset: 'beerfiesta',
  token: '[auth token here]'
})

// Fetching:
client.fetch(
  'beerfiesta.beer[rating > $ratingThreshold] {name, rating}',
  {$ratingThreshold: 95},
  (err, response) => {
    if (err) {
      throw err
    }

    response.result.forEach(beer => {
      console.log(`${beer.name} has a rating of ${beer.rating}`)
    })
  }
)

// Fetch a specific document by ID:
client.getDocument('beerfiesta/someId', (err, beer) => {
  if (err) {
    throw err
  }
  
  console.log(beer)
})

// Creating:
client.create({
  _type: 'beerfiesta.brewery',
  companyName: 'Bengler',
  location: {
    lat: 59.923868,
    lng: 10.757842
  }
}, (err, response) => {
  if (err) {
    throw err
  }

  console.log(`Document ID: ${response.results[0].id}`)
})

// Updating:
client.update(
  'beerfiesta/S0YNUJXt2Ko0yjIDnZ9T', // Document ID
  { // Update patch, see Gradient wiki for update operations
    companyName: 'Bengler AS',
    location: {
      lat: 59.9238681
    }
  },
  (err, response) => { /* handle it */ }
)

// Deleting:
client.delete(
  'beerfiesta/S0YNUJXt2Ko0yjIDnZ9T', // Document ID
  (err, response) => { /* handle it */ }
)

License

MIT-licensed. See LICENSE.

/@sanity/gradient-client/

    Package Sidebar

    Install

    npm i @sanity/gradient-client

    Weekly Downloads

    5

    Version

    0.1.4

    License

    MIT

    Last publish

    Collaborators

    • 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