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.

    Install

    npm i @sanity/gradient-client

    DownloadsWeekly Downloads

    60

    Version

    0.1.4

    License

    MIT

    Last publish

    Collaborators

    • nina.andal
    • rankers
    • snorreeb
    • mattcraig
    • dkhuntrods
    • vincentquigley
    • stipsan
    • michael-sanity
    • rubioz
    • tonina
    • ritasdias
    • simeonsanity
    • kmelve
    • ricokahler
    • bjoerge
    • rexxars
    • skogsmaskin
    • simenss
    • hdoro
    • robinpyon
    • mariuslundgard
    • sanity-io
    • evenw
    • radhe_sanity
    • rbotten
    • vicbergquist
    • judofyr
    • obliadp
    • dcilke
    • fredcarlsen
    • jorn_georg
    • hermanw
    • svirs
    • mikolajsanity
    • sgulseth
    • atombender