deepstream.io

Delete record field via deepstream Record


I'm looking for a way to clean document nested field, for example, consider I have a JSON object:

{
  fieldToClean: {
    fieldA: '..',
    fieldB: '..',
    fieldC: '..'
  }
}

I know that I don't need fieldB anymore. I found one solution that looks like:

var record = deepstream.record.getRecord('<proper path>')
record.whenReady(function(){
  var fieldToClean = record.get('fieldToClean')
  delete fieldToClean.fieldB
  record.set('fieldToClean', fieldToClean)
})

I wonder if deepstream provides something like:

record.delete('fieldToClean.fieldB')

or

record.set('fieldToClean.fieldB', undefined)

I wasn't able to find something like this in documentation.

Thank you for your time!


Solution

  • There's actually an issue for this open, our main design question is around deleting an index in array. Is that a null or splice? Be great to have your feedback!

    https://github.com/deepstreamIO/deepstream.io/issues/29