FaunaDB更新记录仅更新tstimestamp,没有其他更改

问题描述

我正在使用Netlify推荐的FaunaDB

这是我的更新查询

  const response = await client.query(
  q.Let(

    {

      matchRef: q.Select([0],q.Paginate(q.Match(q.Index("sub_search_by_auth"),auth)))

    },q.Update(q.Var("matchRef"),{subscription}) // do I need to put the sub inside a data property?

  )

); 

说我在数据库中有一条记录:

{
  "ref": Ref(Collection("subscriptions"),"275059653136613888"),"ts": 1598577889893000,"data": {
    "endpoint": "https://fcm.googleapis.com/fcm/send/djvbe6Pbu-Q:APA91bGicad","keys": {
      "p256dh": "BJ99-332131df","auth": "12332dfsdfsdfs"
    }
  }
}

我将其keys.p256dh从BJ99-332131df更新为BJ99-332131dfOOOOAAA 并添加一个名为Extra的新属性,看起来像这样:

{
  "ref": Ref(Collection("subscriptions"),"keys": {
      "p256dh": "BJ99-332131dfOOOOAAA","auth": "12332dfsdfsdfs"
    },"extra": {
         "email": "[email protected]"
     }
  }
}

然后使用上述更新查询来更新该记录。

我唯一能看到的变化就是ts,没别的。

解决方法

是的,您需要将更新包裹在data中。希望这个link有帮助。