#How do I update a singleton using the SDK?

10 messages · Page 1 of 1 (latest)

tender ember
#

Hi, I'm trying to update a singleton using the SDK. Sadly, the only thing that's actually updating is the date_updated field, no matter what I do.
I tried using:

  • updateOne(1, updates) - /foo/1 does not exist
  • updateByQuery({ id: { _eq: 1 } }, updates) - only updates the date_updated field
  • updateMany(1, updates), updateMany(null, updates) - only updates the date_updated field
    I'm kind of lost. Right now I'm pondering if maybe I should just resign from using singletons... Anything I'm not seeing? I already checked multiple times if I'm passing the correct updates, so no luck there.
    Important to note: the revisions are actually showing up in the panel, but the data I'm passing does not change.

Full code:

const updates = {
  full_margin: 100,
  full_minimum: 100,
  product_margin: 100,
  product_minimum: 100
};
const newData = (await api.items('global_margins').updateMany(null, updates)).data;```

And I'm also including a screenshoot of the singleton panel in admin.
sturdy vault
tender ember
#

That doesn't seem to be a function though

#

api.items('global_margins').upsertSingleton(updates)

#

Maybe I'm misunderstanding how I'm supposed to call it

sturdy vault
#

Ahh misread your question, thought you was using the extensions sdk

#

I believe it's like api.singleton('global_margins').update/read?

#

@tender ember

tender ember
#

Omg thank you! That's correct. It's not in the docs though - or maybe I'm just blind. Thank you for your help!