Socket
Socket
Sign inDemoInstall

@sanity/client

Package Overview
Dependencies
Maintainers
6
Versions
986
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/client - npm Package Compare versions

Comparing version 0.104.34 to 0.104.38

2

package.json
{
"name": "@sanity/client",
"version": "0.104.34",
"version": "0.104.38",
"description": "Client for retrieving data from Sanity",

@@ -5,0 +5,0 @@ "main": "lib/sanityClient.js",

@@ -31,3 +31,3 @@ # Sanity client

Initializes a new Sanity Client. Required options are `projectId`, `dataset` and `token`.
Initializes a new Sanity Client. Required options are `projectId` and `dataset`.

@@ -37,3 +37,3 @@ ## Fetch a single document

```js
client.getDocument('bikeshop.bike-123').then(bike => {
client.getDocument('bike-123').then(bike => {
console.log(`${bike.name} (${bike.seats} seats)`)

@@ -46,3 +46,3 @@ })

```js
const query = '*[is "bikeshop.bikes" && seats >= $minSeats] {name, seats}'
const query = '*[is "bike" && seats >= $minSeats] {name, seats}'
const params = {minSeats: 2}

@@ -65,3 +65,3 @@

```js
const query = '*[is "bikeshop.comment" && authorId != $ownerId]'
const query = '*[is "comment" && authorId != $ownerId]'
const params = {ownerId: 'bikeOwnerUserId'}

@@ -89,3 +89,3 @@

const doc = {
_type: 'bikeshop.bike',
_type: 'bike',
name: 'Bengler Tandem Extraordinaire',

@@ -96,3 +96,3 @@ seats: 2

client.create(doc).then(res => {
console.log(`Bike was created, document ID is ${res.documentId}`)
console.log(`Bike was created, document ID is ${res._id}`)
})

@@ -103,3 +103,3 @@ ```

Create a document. Argument is a plain JS object representing the document. It must contain a `_type` attribute in `<schema>.<type>` format. It *may* contain an `_id`, in `<dataset>.<someId>` format.
Create a document. Argument is a plain JS object representing the document. It must contain a `_type` attribute. It *may* contain an `_id`. If an ID is not specified, it will automatically be created.

@@ -111,3 +111,3 @@

client
.patch('bikeshop.bike-123') // Document ID to patch
.patch('bike-123') // Document ID to patch
.set({inStock: false}) // Shallow merge

@@ -133,3 +133,3 @@ .inc({numSold: 1}) // Increment field by count

```js
client.delete('bikeshop.bike-123')
client.delete('bike-123')
.then(res => {

@@ -151,3 +151,3 @@ console.log('Bike deleted')

const namePatch = client
.patch('bikeshop.bike-310')
.patch('bike-310')
.set({name: 'A Bike To Go'})

@@ -157,3 +157,3 @@

.create({name: 'Bengler Tandem Extraordinaire', seats: 2})
.delete('bikeshop.bike-123')
.delete('bike-123')
.patch(namePatch)

@@ -176,3 +176,3 @@ .commit()

.create({name: 'Bengler Tandem Extraordinaire', seats: 2})
.patch('bikeshop.bike-123', p => p.set({inStock: false}))
.patch('bike-123', p => p.set({inStock: false}))
.commit()

@@ -209,4 +209,4 @@ .then(res => {

const transaction = new sanityClient.Transaction()
.create({_id: 'foo.123', name: 'FooBike'})
.delete('foo.bar')
.create({_id: '123', name: 'FooBike'})
.delete('someDocId')

@@ -220,7 +220,4 @@ client.mutate(transaction)

A few notes on this approach:
An important note on this approach is that you cannot call `commit()` on transactions or patches instantiated this way, instead you have to pass them to `client.mutate()`
* You cannot call `commit()` on transactions or patches instantiated this way, instead you have to pass them to `client.mutate()`
* Documents passed to `create`, `createIfNotExists` and `createOrReplace` needs to include an `_id` property, since it cannot infer which dataset it should belong to. If you want Sanity to auto-generate one for you, set `_id` to `<datasetName>.`
## Get client configuration

@@ -246,2 +243,2 @@

Set client configuration. Required options are `projectId`, `dataset` and `token`.
Set client configuration. Required options are `projectId` and `dataset`.

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc