A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1803 below:

dataset.save() should work with entities using the new datastore.KEY symbol · Issue #1803 · googleapis/google-cloud-node · GitHub

Before v0.5.0, we could do something like this:

const key = datastore.key(['Some','thing'])
datastore.get(key,(err,entity) => {
  entity.data.foo = 'bar'
  datastore.save(entity,callback)
})

This worked because datastore.save's parameter and the object gotten from datastore.get had the same structure, but now datastore.save has to be called with {key:<key>,data:<data>}, it's more difficult to do simple updates to entities. Right now we have to do this:

const key = datastore.key(['Some','thing'])
datastore.get(key)
  .then(([entity]) => {
    entity.foo = 'bar'
    return datastore.save({
      key: key,
      data: entity
    })
  })

but I think this should work:

const key = datastore.key(['Some','thing'])
datastore.get(key)
  .then(([entity]) => {
    entity.foo = 'bar'
    return datastore.save(entity)
  })

Personally I preferred the old version where everything was {key:<key>,data:<data>} because it was more straightforward and didn't require a reference back to the datastore object, but if it's going to be changed it should at least be consistent across the board.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4