SlicingDice Documentation

SlicingDice API Docs

Welcome to the SlicingDice API documentation. You'll find comprehensive guides and documentation to help you start working with SlicingDice as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Documentation

Inserting on different tables


The concept of a table on SlicingDice is a bit different than on relational databases.

On SlicingDice tables are used when you want to store the same data (or very similar), but associating it to different entity ids. A different way to think about it is if you want to store your data, but in different "dimensions", for example: storing browsing behavior data for a user table and a web pages table.

Default Table

If you don't add any table when creating a new database, SlicingDice automatically creates a default table for you to store data.

If you do not specify the table parameter on your request, either insertion or query, under the hood SlicingDice is always using the default table.

You can read more about it accessing the how to create tables documentation page.

Table usage example

See below the similarity of SQL table selection and the SlicingDice JSON, when inserting data.

SQL equivalent
SlicingDice "table" parameter (JSON)

Insertion example

INSERT INTO default_table
(entity-id, name, age)
VALUES
('UUID-01', 'Jeff', 25);

Insertion example

{
    "UUID-01": {
        "table": "default",
        "name": "Jeff",
        "age": 25
    }
}

Insertion request for a single table

As you can see below, we are making a single request inserting data on the users table.

curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "UUID-01": {
            "table": "users",
            "name": "Jeff",
            "age": 25
        },
        "auto-create": ["table", "column"]
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

insert_data = {
    "UUID-01": {
        "table": "users",
        "age": 25,
        "name": "Jeff"
    },
    "auto-create": [
        "table", 
        "column"
    ]
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject insertData = new JSONObject()
        .put("UUID-01", new JSONObject()
            .put("table", "users")
            .put("age", 25)
            .put("name", "Jeff"))
        .put("auto-create", new JSONArray()
            .put("table")
            .put("column"));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

insert_data = {
    "UUID-01" => {
        "table" => "users",
        "age" => 25,
        "name" => "Jeff"
    },
    "auto-create" => [
        "table", 
        "column"
    ]
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const insertData = {
    "UUID-01": {
        "table": "users",
        "age": 25,
        "name": "Jeff"
    },
    "auto-create": [
        "table", 
        "column"
    ]
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$insertData = array(
    "UUID-01" => array(
        "table" => "users",
        "age" => 25,
        "name" => "Jeff"
    ),
    "auto-create" => array(
        "table", 
        "column"
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var insertData = new Dictionary<string, dynamic>{
                {"UUID-01", new Dictionary<string, dynamic>{
                    {"table", "users"},
                    {"age", 25},
                    {"name", "Jeff"}
                }},
                {"auto-create", new List<dynamic>{
                    "table", 
                    "column"
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    insertData := map[string]interface{}{
        "UUID-01": map[string]interface{}{
            "table": "users",
            "age": 25,
            "name": "Jeff",
        },
        "auto-create": []interface{}{
            "table",
            "column",
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Insertion request for two tables

As you can see below, we are making a single request inserting data on two tables, the users and the page table.

curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "UUID-01": {
            "table": "users",
            "name": "Jeff",
            "age": 25
        },
        "/online-demo": {
            "table": "page",
            "users": "UUID-01",
            "referer": "google"
        },
        "auto-create": ["table", "column"]
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

insert_data = {
    "UUID-01": {
        "table": "users",
        "age": 25,
        "name": "Jeff"
    },
    "auto-create": [
        "table", 
        "column"
    ],
    "/online-demo": {
        "table": "page",
        "referer": "google",
        "users": "UUID-01"
    }
}

print(slicingdice.insert(insert_data))

import com.slicingdice.jslicer.SlicingDice;
import java.io.IOException;
import org.json.JSONObject;
import org.json.JSONArray;

public class Example {
    public static void main(String[] args) throws IOException {
        SlicingDice slicingdice = new SlicingDice("MASTER_API_KEY", true);

        JSONObject insertData = new JSONObject()
        .put("UUID-01", new JSONObject()
            .put("table", "users")
            .put("age", 25)
            .put("name", "Jeff"))
        .put("auto-create", new JSONArray()
            .put("table")
            .put("column"))
        .put("/online-demo", new JSONObject()
            .put("table", "page")
            .put("referer", "google")
            .put("users", "UUID-01"));

        JSONObject result = slicingdice.insert(insertData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY', uses_test_endpoint: true)

insert_data = {
    "UUID-01" => {
        "table" => "users",
        "age" => 25,
        "name" => "Jeff"
    },
    "auto-create" => [
        "table", 
        "column"
    ],
    "/online-demo" => {
        "table" => "page",
        "referer" => "google",
        "users" => "UUID-01"
    }
}

puts slicingdice.insert(insert_data)

const SlicingDice = require('slicerjs');

const usesTestEndpoint = true;
const slicingdice = new SlicingDice({masterKey: 'MASTER_API_KEY'}, usesTestEndpoint);

const insertData = {
    "UUID-01": {
        "table": "users",
        "age": 25,
        "name": "Jeff"
    },
    "auto-create": [
        "table", 
        "column"
    ],
    "/online-demo": {
        "table": "page",
        "referer": "google",
        "users": "UUID-01"
    }
};

slicingdice.insert(insertData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});

<?php
use Slicer\SlicingDice;
$usesTestEndpoint = true;
$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"), $usesTestEndpoint);

$insertData = array(
    "UUID-01" => array(
        "table" => "users",
        "age" => 25,
        "name" => "Jeff"
    ),
    "auto-create" => array(
        "table", 
        "column"
    ),
    "/online-demo" => array(
        "table" => "page",
        "referer" => "google",
        "users" => "UUID-01"
    )
);

print_r($slicingdice->insert($insertData));
?>
using System.Collections.Generic;
using Slicer;
using Newtonsoft.Json;

namespace SlicerTester.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            var slicingdice = new SlicingDice(masterKey: "MASTER_API_KEY", usesTestEndpoint: true);

            var insertData = new Dictionary<string, dynamic>{
                {"UUID-01", new Dictionary<string, dynamic>{
                    {"table", "users"},
                    {"age", 25},
                    {"name", "Jeff"}
                }},
                {"auto-create", new List<dynamic>{
                    "table", 
                    "column"
                }},
                {"/online-demo", new Dictionary<string, dynamic>{
                    {"table", "page"},
                    {"referer", "google"},
                    {"users", "UUID-01"}
                }}
            };

            var result = slicingdice.Insert(insertData);
            System.Console.WriteLine(JsonConvert.SerializeObject(result).ToString());
        }
    }
}
package main
import (
    "fmt"
    "github.com/SlicingDice/slicingdice-go/slicingdice"
)
func main() {
    keys := new(slicingdice.APIKey)
    keys.MasterKey = "MASTER_API_KEY"
    slicingdice := slicingdice.New(keys, 60)
    slicingdice.Test = true

    insertData := map[string]interface{}{
        "UUID-01": map[string]interface{}{
            "table": "users",
            "age": 25,
            "name": "Jeff",
        },
        "auto-create": []interface{}{
            "table",
            "column",
        },
        "/online-demo": map[string]interface{}{
            "table": "page",
            "referer": "google",
            "users": "UUID-01",
        },
    }

    fmt.Println(slicingdice.Insert(insertData))
}

Inserting on different tables