Delete a field

This tutorial shows you how to delete a field in a document.

View the document

As an example, look at the fields in an existing document. If you’re following this tutorial, use the document id of one of your documents.

CoffeeBean.byId("374312704818544708")
{
  id: "374312704818544708",
  coll: CoffeeBean,
  ts: Time("2023-08-28T14:01:02.910Z"),
  Species: "Arabica",
  Owner: "Coffee Co., Inc.",
  Country_of_Origin: "USA",
  Harvest_Year: 2022,
  Quality_Parameters: {
    Aroma: 8.67,
    Flavor: 8.83,
    Balance: 8.42
  },
  Altitude: {
    unit_of_measurement: "m",
    mean: 2075
  }
}

Delete the field

Assuming that the Altitude field is not of interest, so you want to delete it, update the field, setting the value of Altitude to null to delete it:

CoffeeBean.byId("374312704818544708")!.update(
  { Altitude: null }
)
{
  id: "374312704818544708",
  coll: CoffeeBean,
  ts: Time("2023-08-28T14:04:33.185Z"),
  Species: "Arabica",
  Owner: "Coffee Co., Inc.",
  Country_of_Origin: "USA",
  Harvest_Year: 2022,
  Quality_Parameters: {
    Aroma: 8.67,
    Flavor: 8.83,
    Balance: 8.42
  }
}

 

The response shows that the Altitude field is deleted.

Also, note that deleted fields are not saved.

See also

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!