Dark Mode

Inserting data

Prerequisites

If you have created schema for insertion, now you are ready to write data into the database.

First, let's navigate to your new keyspace library inside the playground.Change the location to http://$ASTRACLUSTERID-$ASTRA_REGION.apps.astra.datastax.com/api/graphql/library and add a couple of books to the book table:

The insertion is straightforward.The title and author are specified, and the title is returned in response to a successful insertion.Only the required fields must be specified, and any fields can be returned in the response.This same operation can update stored data, as insertions are upserts in all cases.

Conditional insertion

Insert arrays and UDTs

Inserting arrays and UDTs requires a few extra embellishments:

Note the use of square brackets around arrays of objects, with commas separatingarray items.