/tablesdb/{databaseId}/tables/{tableId}/columns/relationshipEscopo tables.writeSDK: só @owbase/node
Cria uma coluna de relação. Saiba mais sobre colunas de relação.
Parâmetros
Seção intitulada “Parâmetros”databaseId string obrigatório
ID do banco.
tableId string obrigatório
ID da tabela.
relatedTableId string obrigatório
ID da tabela relacionada.
type RelationshipType obrigatório
Tipo de relação. Valores possíveis: oneToOne, oneToMany, manyToOne, manyToMany. Valores: oneToOne, manyToOne, manyToMany, oneToMany.
twoWay boolean
É de mão dupla?
key string
Chave da coluna.
twoWayKey string
Chave da coluna de mão dupla.
onDelete RelationMutate
Regra ao excluir. Valores possíveis: cascade, restrict, setNull. Valores: cascade, restrict, setNull.
description string
Descrição opcional da coluna.
Acesso: chave de API com o escopo tables.write (também aceita collections.write, columns.write, attributes.write).
Respostas
Seção intitulada “Respostas”202Sucesso400Parâmetro inválido ou faltando401Sem sessão, sem permissão no recurso ou chave sem o escopo404Recurso do caminho não encontrado429Limite de requisiçõesTodo erro vem como JSON com code, type e message: veja Erros.
import { Client, TablesDB, RelationshipType, RelationMutate } from '@owbase/node';
const client = new Client() .setEndpoint('https://cloud.owbase.dev/v1') // endpoint da API .setProject('<YOUR_PROJECT_ID>') // ID do projeto .setKey('<YOUR_API_KEY>'); // chave de API (só no servidor)
const tablesDB = new TablesDB(client);
const result = await tablesDB.createRelationshipColumn({ databaseId: '<DATABASE_ID>', tableId: '<TABLE_ID>', relatedTableId: '<RELATED_TABLE_ID>', type: RelationshipType.OneToOne, twoWay: false, // opcional key: '<KEY>', // opcional twoWayKey: '<TWO_WAY_KEY>', // opcional onDelete: RelationMutate.Cascade, // opcional description: '<DESCRIPTION>', // opcional});curl -X POST "https://cloud.owbase.dev/v1/tablesdb/<DATABASE_ID>/tables/<TABLE_ID>/columns/relationship" \ -H "X-Owbase-Project: <PROJECT_ID>" \ -H "X-Owbase-Key: $OWBASE_API_KEY" \ -H "Content-Type: application/json" \ -d '{"relatedTableId":"<RELATED_TABLE_ID>","type":"oneToOne"}'{ "key": "fullName", "description": "Name shown on the public profile.", "type": "string", "status": "available", "error": "string", "required": true, "array": false, "$createdAt": "2020-10-15T06:38:00.000+00:00", "$updatedAt": "2020-10-15T06:38:00.000+00:00", "relatedTable": "table", "relationType": "oneToOne|oneToMany|manyToOne|manyToMany", "twoWay": false, "twoWayKey": "string", "onDelete": "restrict|cascade|setNull", "side": "parent|child"}As descrições desta página são traduções das que vêm da especificação da API do servidor (licença BSD-3-Clause), e os exemplos vêm do gerador de SDKs (licença MIT). Os avisos completos estão no arquivo NOTICE dos pacotes @owbase/web e @owbase/node.