カロリー カウンターに取り組んでおり、新しいレシピを作成できますが、材料を更新しようとすると問題が発生します。
次の MQL で成分を作成できます。
{
  id: recipeId,
  '/food/recipe/ingredients': {
    create: 'unless_exists',
    id: null,
    quantity: parseFloat( row.$quantity.val() ),
    unit: {
      id: row.$units.val()
    },
    ingredient: {
      id: row.ingredientId
    }
  }
}
ただし、材料の量を変更すると (たとえば 2 杯から 3 杯)、このクエリは新しい材料を作成します。エントリを更新しようとしました。これまでのところ、私は試しました:
{
  connect: 'update',
  id: row.rowId,
  type: '/food/recipe_ingredient',
  quantity: parseFloat( row.$quantity.val() ),
  unit: {
    id: row.$units.val()
  },
  ingredient: {
    id: row.ingredientId
  }
}
これにより、次のエラーが発生します: Can't use [], [{}] or {} in a write。
{
  connect: 'update',
  id: row.rowId,
  type: '/food/recipe_ingredient',
  quantity: parseFloat( row.$quantity.val() )
}
エラーが発生します: Can't use 'connect' at the root of the query。
 {
   id: recipeId,
   '/food/recipe/ingredients': {
     connect: 'update',
     id: row.rowId,
     type: '/food/recipe_ingredient',
     quantity: parseFloat( row.$quantity.val() )
   }
 }
エラーが表示されます: Can't use 'connect': 'update' on a non-unique master property。
{
  id: row.rowId,
  type: '/food/recipe_ingredient',
  quantity: {
    connect: 'update',
    value: parseFloat( row.$quantity.val() )                                                                                               
  }
}
エラーが発生します:This value is already in use. Please delete it first.古い成分を削除して新しい成分を追加する唯一の方法はありますか?
古いエントリを削除して置き換えることが唯一の方法である場合、次のようなクエリを使用して個別にではなく、すべての成分を一度に削除する方法はありますか?
{
  id: recipeId,
  '/food/recipe/ingredients': {
    connect: 'delete',
    id: row.rowId
  }
}