Check if a tuple exists on write
# spicedb
j
definition user {} definition schema { relation reader: user permission view = reader } for above schema i am writing relathionship as { "updates": [ { "operation": "OPERATION_TOUCH", "relationship": { "resource": { "objectType": "schema", "objectId": "schema1" }, "relation": "reader", "subject": { "object": { "objectType": "user", "objectId": "jayesh" } } } } ] } i am doing this through java sdk using authzed api, i have requirement for checking in the beginning that objectId or subjectId exists in the database or not?
v
Are you looking to determine if this tuple exists? If so you can use "CREATE" instead of "TOUCH", which will make it fail if the tuple exists
j
okay thanks
also, i need to midify my schema in spicedb but it says relation exists, so i need to delete my whole schema
is there any api or other way to do it?
v
what is "midify"? Do you mean "minify"? SpiceDB will prevent you from executing
WriteSchema
if it causes a relation with data to be dropped, as a precaution. There is no API to force delete the schema in this case, you have to drop the data first. You can use
zed
command line to do this easily by specifying the resource and relation:
Copy code
~ % zed relationship delete --help
Deletes a relationship

Usage:
  zed relationship delete <resource:id> <relation> <subject:id#optional_subject_relation> [flags]

Flags:
  -b, --batch-size int   batch size when deleting streams of relationships from stdin (default 100)
  -h, --help             help for delete
      --json             output as JSON

Global Flags:
      --certificate-path string     path to certificate authority used to verify secure connections
      --endpoint string             spicedb gRPC API endpoint
      --insecure                    connect over a plaintext connection
      --log-format string           format of logs ("auto", "console", "json") (default "auto")
      --log-level string            verbosity of logging ("trace", "debug", "info", "warn", "error") (default "info")
      --no-verify-ca                do not attempt to verify the server's certificate chain and host name
      --permissions-system string   permissions system to query
      --skip-version-check          if true, no version check is performed against the server
      --token string                token used to authenticate to SpiceDB
j
i meant modify, sorry for typo
delete whole schema
v
yeah, as I indicated yesterday, no way to do that without dropping all relationships
j
okay, thanks
6 Views