Create an index (unique fields)
const url = 'https://your-app-domain/v1/db/example/createIndex';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"collection":"example","keys":{"additionalProperty":1},"unique":true,"name":"example","writeConcern":{"w":"log"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://your-app-domain/v1/db/example/createIndex \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "collection": "example", "keys": { "additionalProperty": 1 }, "unique": true, "name": "example", "writeConcern": { "w": "log" } }'A unique single-field index makes the field unique (checked on every write). Other indexes are accepted for driver compatibility and change nothing: queries run in memory.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The database id (the last part of the connection string).
Request Bodyrequired
Section titled “Request Bodyrequired”Responses
Section titled “Responses”Success
object
Example generated
{ "name": "example"}Invalid request (BadRequest, ValidationError, BadValue, ImmutableField, InvalidName).
object
object
object
Example generated
{ "error": { "code": "example", "message": "example", "details": {} }}Missing, wrong, revoked or expired connection string, or Google access was removed (Unauthorized).
object
object
object
Example generated
{ "error": { "code": "example", "message": "example", "details": {} }}Read-only connection string (ReadOnlyKey) or a database you can only view (ReadOnly).
object
object
object
Example generated
{ "error": { "code": "example", "message": "example", "details": {} }}Unknown collection (NamespaceNotFound) or action (UnknownAction).
object
object
object
Example generated
{ "error": { "code": "example", "message": "example", "details": {} }}A unique field already has this value (DuplicateKey).
object
object
object
Example generated
{ "error": { "code": "example", "message": "example", "details": {} }}Request body over 1 MB (PayloadTooLarge).
object
object
object
Example generated
{ "error": { "code": "example", "message": "example", "details": {} }}Too many requests (RateLimited). Wait for Retry-After seconds.
object
object
object
Example generated
{ "error": { "code": "example", "message": "example", "details": {} }}The database file is unavailable (DatabaseUnavailable) or Google Drive is busy (DriveUnavailable, retry).
object
object
object
Example generated
{ "error": { "code": "example", "message": "example", "details": {} }}The owner’s Google Drive is full (DriveFull).
object
object
object
Example generated
{ "error": { "code": "example", "message": "example", "details": {} }}Made by Faeiz Furqan