Skip to content

Commit

Permalink
fix: Use client.save() to create / mutate data
Browse files Browse the repository at this point in the history
By not using it, we dont enforce cozyMetadata.
So let's use CozyClient.save() to have these
cozyMetadata.
  • Loading branch information
Crash-- committed Dec 28, 2023
1 parent 317c19c commit c7165c2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/targets/services/myselfFromIdenties.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ global.fetch = fetch
const client = new CozyClient({
uri: process.env.COZY_URL.trim(),
token: process.env.COZY_CREDENTIALS.trim()
}).getStackClient()
const contactCollection = client.collection('io.cozy.contacts')
})
const contactCollection = client.getStackClient().collection('io.cozy.contacts')

async function main() {
const newIdentity = getIdentity()
Expand All @@ -18,10 +18,11 @@ async function main() {
if (currentMyselfContact) {
log('info', `Updating the me contact with new attributes`)
updateMyselfWithIdentity(newIdentity, currentMyselfContact)
await contactCollection.update(currentMyselfContact)
await client.save(currentMyselfContact)
} else {
log('info', `The "me" contact could not be found, creating it`)
await contactCollection.create({
await client.save({
_type: 'io.cozy.contacts',
me: true,
...newIdentity.contact
})
Expand Down

0 comments on commit c7165c2

Please sign in to comment.