Traverzer
  • About
  • Basics
    • Insert & Update
    • Fetch & Find
    • Delete
  • Reference
    • PUT
    • POST
    • DELETE
Powered by GitBook
On this page
Edit on GitHub
  1. Basics

Insert & Update

With Traverzer doing an insert or an update for a record is the same endpoint. If the record doesn't exist then a record and all fields will be inserted, otherwise the fields specified will be updated on the record.

You are welcome to insert an existing identifier on your records or use the Traverzer Key, tvzr_key, which is always generated for a record. The Traverzer Key is completely unique across all tables and records in the database.

You'll notice that the one main difference from what you would likely send today in a request is that the fields are wrapped in an object which is the table name. In the following example the user, profile, and address fields are considered table names because they are defined as objects. Assuming the database is empty, this example would create a user, profile, and address table with 1 record in each.

Request

fetch('https://api.traverzer.tech/', { 
    method: 'PUT', 
    headers: { 
        'Content-Type': 'application/json',
        'Authorization': <token>
    }, 
    body: JSON.stringify({ 
        user: { 
            username: "johndoe", 
            email: "johndoe@example.com", 
            profile: { 
                name: "John Doe", 
                address: { 
                    street: "123 Main St", 
                    city: "Somewhere", 
                    state: "CA", 
                    postalCode: "90210", 
                    country: "USA" 
                }, 
            } 
        } 
    }) 
});

Successful Response

{ 
    "user": { 
        "tvzr_key": "s9eujs0l",
        "username": "johndoe", 
        "email": "johndoe@example.com", 
        "profile": { 
            "tvzr_key": "29d8d7u7",
            "name": "John Doe", 
            "address": { 
                "tvzr_key": "sis28ds",
                "street": "123 Main St", 
                "city": "Somewhere", 
                "state": "CA", 
                "postalCode": "90210", 
                "country": "USA" 
            }, 
        } 
    } 
}

Last updated 4 months ago