Igor.Shmukler
09/18/2022, 6:15 PMwriteRelationships
from NodeJS SDK. I assumed that write relationships is an equivalent of zed relationship create ...
. However, it is NOT working for me, unlike zed
.
const subjectRef = v1.ObjectReference.create({
objectType: 'user',
objectId: `${userId}`
});
// zed relationship create organization:1 owner user:2
const orgRef = v1.ObjectReference.create({
objectType: 'organization',
// eslint-disable-next-line camelcase
objectId: reference_id
});
const writeRelationships = v1.WriteRelationshipsRequest.create({
resource: orgRef,
permission: role,
subject: v1.SubjectReference.create({
object: subjectRef
})
});
console.log(
// eslint-disable-next-line camelcase
`write ${role} relationship between organization:${reference_id} and user:${userId}`
);
const status = await writeRelationshipsPromise(writeRelationships);
console.log('write relationship status:', status);
When I execute my code, it prints:
write manage_billing relationship between organization:1 and user:5
write relationship status: { writtenAt: { token: 'GgQKAjM3' } }
Yet, the relationship is not there, or maybe SpiceDB started creating it and did not finish.
I checked out the actual database, and relation_tuple
does not have the new relationships, yet relation_tuple_transaction
does have something that seems like an unfinished transaction, MAYBE.