Skip to main content


Address Book App Quickstart

Let’s take 5 minutes to create a stateful-serverless backend for a simple Address Book. It's going to run globally distributed with local read-write latencies around 50ms.

We are going to walk through 4 steps:

  • Create a collection and add some data to it.
  • Query that data.
  • Save the query (A saved query is called a Query Worker).
  • Execute the Query Worker!

First things first, if you don't already have a Macrometa account go create a free one and mosey on back.

Step 1: Create a Collection

Let’s start by clicking the COLLECTIONS tab in the left nav and then New Collection on the right. Select the Document option, give it the name addresses, and save it.

Note: The collection addresses that you just created is now distributed to every location in the fabric!


Step 2: Add some data to your new collection and query it

Now, click the QUERIES tab in the left nav to open the C8QL query editor. Copy and paste the query below into the editor and click Run Query a couple times.

// Query to insert addresses
FOR persons IN [
{ firstname: "Captain", lastname: "Nemo", email: "[email protected]" },
{ firstname: "Pierre", lastname: "Aronnax", email: "[email protected]" },
{ firstname: "Ned", lastname: "Land", email: "[email protected]" },
{ firstname: "Cyrus", lastname: "Smith", email: "[email protected]" },
{ firstname: "Tom", lastname: "Ayrton", email: "[email protected]" },
{ firstname: "Jules", lastname: "Verne", email: "[email protected]" }
INSERT persons INTO addresses

Your Query Result will be empty brackets, but if you click on Profile button you can checkout what just happened along with some performance details. Your data was just written to the location you're currently logged into and replicated across all of the nodes in your fabric.

Now, let's query the data you just added to your collection. Copy the below query and replace the INSERT query currently in the editor with it.

FOR docs IN addresses RETURN docs 

You should see the data you just saved returned.

Ok, now we are going to save this query. Saving it will turn it into a Query Worker.

Step 3: Save the Query

Click the Save Query button and name the saved query getAddresses

Now, in around 50ms, you have a globally distributed stateful-serverless endpoint.


Step 4: Execute the Query Worker

Now that you've saved the query click on the API Usage button, and we automatically generate a Query Worker (Exactly like a serverless function, but a save query instead of a function)!


Next Steps

Nice job you totally rocked that quickstart!

Now let's build out the REST of our CRUD API. Just create a Query Worker for each of these queries.


INSERT {firstname:@firstName,
INTO addresses


FOR entry 
IN addresses
RETURN entry


REMOVE @_key 
IN addresses


UPDATE @_key WITH { firstname:@firstName, 
IN addresses

Sweet, so now you have a full functional API for your app. We made a front-end for you to take your new backend for a spin.

Now that you've build your app, full stack, you can dig into the docs and see all the rad things Macrometa can help you build >> Essentials guide.