Need help. My code just runs to an error. It says: Cannot write a scoped ref.
Maybe it has to do with:
q.Collection("Projects", q.Database("Apps"))
Here's my code:
let data = {
project: {
id: 9273727,
name: "test",
author: "Matthieu"
},
content: []
}
client.query(q.Create(q.Collection("Projects", q.Database("Apps")), {data}))
.then(res => console.log(res))
.catch(error => console.log(error));
The error is correct. You can't do writes with scoped refs. Only read. You have to initiate your client with a secret that belongs to the database you want to write in. If you have a admin key you can create a scoped secret. Format it like so
{{serverKey}}:{{dbName}}:{{role}}
. Role could beadmin
or any other role.