Ir al contenido
v2.7

Crear fila

Create a new Row.

POST/tablesdb/{databaseId}/tables/{tableId}/rowsAlcance rows.write

Create a new Row. Before using this route, you should create a new table resource using either a server integration API or directly from your database console.

databaseId string obligatorio

Database ID.

tableId string obligatorio

Table ID. You can create a new table using the Database service server integration. Make sure to define columns before creating rows.

rowId string obligatorio

Row ID. Choose a custom ID or generate a random ID with ID.unique(). Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

data object obligatorio

Row data as JSON object.

permissions string[]

An array of permissions strings. By default, only the current user is granted all permissions. Learn more about permissions.

transactionId string

Transaction ID for staging the operation.

Acceso: clave de API con el alcance rows.write (también acepta documents.write) o sesión del usuario, o incluso sin sesión (vale lo que permitan los permisos del recurso).

201Éxito
400Parámetro inválido o faltante
401Sin sesión, sin permiso en el recurso o clave sin el alcance
404Recurso de la ruta no encontrado
429Límite de peticiones

Todo error llega como JSON con code, type y message: consulta Errores.

import { Client, TablesDB, Permission, Role } from '@owbase/web';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
const tablesDB = new TablesDB(client);
const result = await tablesDB.createRow({
databaseId: '<DATABASE_ID>',
tableId: '<TABLE_ID>',
rowId: '<ROW_ID>',
data: {
username: 'walter.obrien',
fullName: "Walter O'Brien",
age: 30,
isAdmin: false,
},
permissions: [Permission.read(Role.any())], // optional
transactionId: '<TRANSACTION_ID>', // optional
});
console.log(result);
Respuesta201 Created
{
"$id": "5e5ea5c16897e",
"$sequence": "1",
"$tableId": "5e5ea5c15117e",
"$databaseId": "5e5ea5c15117e",
"$createdAt": "2020-10-15T06:38:00.000+00:00",
"$updatedAt": "2020-10-15T06:38:00.000+00:00",
"$permissions": [
"read(\"any\")"
]
}

Las descripciones de esta página vienen de la especificación de la API del servidor (licencia BSD-3-Clause), en inglés, y los ejemplos vienen del generador de SDKs (licencia MIT). Los avisos completos están en el archivo NOTICE de los paquetes @owbase/web y @owbase/node.

¿Te ayudó esta página?