Igor.Shmukler
09/18/2022, 6:50 PMconst 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({
updates: [
RelationshipUpdate.create({
relationship: Relationship.create({
resource: orgRef,
relation: 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);