SlicingDice Documentation

SlicingDice - The All-in-One Solution Documentation

Welcome to the SlicingDice 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    Guides

6. Data Insertion, Update & Deletion

On this page, we present how to make an insertion, update and delete on a SlicingDice database.

Before we start inserting data, let's quickly review the concept of entity, that is necessary to insert data to your database. To do this, quickly recap our Entity/Entities section on SlicingDice Key Concepts page.

This guide is primarily focused on interacting with a database using SQL. If you are looking to use API to insert, update and delete data, check this page.


Inserting data

Below is an insertion example to one entity (UUID-01), using three columns, which two of them are attribute columns (Name and Age) and one is an event column (Clicks).

Entities
Name
Age
Clicks

UUID-01

Jeff

25

Add to Cart - {% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}
Pay Now - {% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}
Support - {% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}

INSERT INTO users ([entity-id], [clicks.0.value], [clicks.0.date], [clicks.1.value], [clicks.1.date], [clicks.2.value], [clicks.2.date], name, age) VALUES ("UUID-01", "Add to Cart", "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}", "Pay Now", "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}", "Support", "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}", "Jeff", 25);
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO users ([entity-id], [clicks.0.value], [clicks.0.date], [clicks.1.value], [clicks.1.date], [clicks.2.value], [clicks.2.date], name, age) VALUES ("UUID-01", "Add to Cart", "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}", "Pay Now", "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}", "Support", "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}", "Jeff", 25);'
curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "UUID-01": {
            "dimension": "users",
            "name": "Jeff",
            "age": 25,
            "clicks": [
                {
                    "value": "Add to Cart",
                    "date": "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}"
                }, {
                    "value": "Pay Now",
                    "date": "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}"
                }, {
                    "value": "Support",
                    "date": "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}"
                }
            ]
        },
        "auto-create": ["dimension", "column"]
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

insert_data = {
    "UUID-01": {
        "dimension": "users",
        "age": 25,
        "name": "Jeff",
        "clicks": [
            {
                "date": "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                "value": "Add to Cart"
            }, 
            {
                "date": "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                "value": "Pay Now"
            }, 
            {
                "date": "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                "value": "Support"
            }
        ]
    },
    "auto-create": [
        "dimension", 
        "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("dimension", "users")
            .put("age", 25)
            .put("name", "Jeff")
            .put("clicks", new JSONArray()
                .put(new JSONObject()
                    .put("date", "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}")
                    .put("value", "Add to Cart"))
                .put(new JSONObject()
                    .put("date", "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}")
                    .put("value", "Pay Now"))
                .put(new JSONObject()
                    .put("date", "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}")
                    .put("value", "Support"))))
        .put("auto-create", new JSONArray()
            .put("dimension")
            .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" => {
        "dimension" => "users",
        "age" => 25,
        "name" => "Jeff",
        "clicks" => [
            {
                "date" => "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                "value" => "Add to Cart"
            }, 
            {
                "date" => "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                "value" => "Pay Now"
            }, 
            {
                "date" => "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                "value" => "Support"
            }
        ]
    },
    "auto-create" => [
        "dimension", 
        "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": {
        "dimension": "users",
        "age": 25,
        "name": "Jeff",
        "clicks": [
            {
                "date": "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                "value": "Add to Cart"
            }, 
            {
                "date": "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                "value": "Pay Now"
            }, 
            {
                "date": "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                "value": "Support"
            }
        ]
    },
    "auto-create": [
        "dimension", 
        "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(
        "dimension" => "users",
        "age" => 25,
        "name" => "Jeff",
        "clicks" => array(
            array(
                "date" => "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                "value" => "Add to Cart"
            ), 
            array(
                "date" => "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                "value" => "Pay Now"
            ), 
            array(
                "date" => "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                "value" => "Support"
            )
        )
    ),
    "auto-create" => array(
        "dimension", 
        "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>{
                    {"dimension", "users"},
                    {"age", 25},
                    {"name", "Jeff"},
                    {"clicks", new List<dynamic>{
                        new Dictionary<string, dynamic>{
                            {"date", "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}"},
                            {"value", "Add to Cart"}
                        }, 
                        new Dictionary<string, dynamic>{
                            {"date", "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}"},
                            {"value", "Pay Now"}
                        }, 
                        new Dictionary<string, dynamic>{
                            {"date", "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}"},
                            {"value", "Support"}
                        }
                    }}
                }},
                {"auto-create", new List<dynamic>{
                    "dimension", 
                    "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{}{
            "dimension": "users",
            "age": 25,
            "name": "Jeff",
            "clicks": []interface{}{
                map[string]interface{}{
                    "date": "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                    "value": "Add to Cart",
                },
                map[string]interface{}{
                    "date": "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                    "value": "Pay Now",
                },
                map[string]interface{}{
                    "date": "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                    "value": "Support",
                },
            },
        },
        "auto-create": []interface{}{
            "dimension",
            "column",
        },
    }

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

Once the database receives your insertion request, it can take up to a few seconds for your data to be available for querying due to our eventual consistency model.

Important

By default, all data inserted to the database is stored in lowercase only. Therefore, the database should not store data that must be case sensitive, such as passwords.


Updating data

Before going into the details about the record update, it's important for you to know what you can and can't do with the record update.

With this feature you can:

  • Update values from desired columns on specified records;
  • Delete values from desired columns on specified records;

You can't:

We will use the data below during the update examples.

Entities
Name
Age
Clicks

UUID-01

Jeff

25

Add to Cart - {% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}
Pay Now - {% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}
Support - {% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}

INSERT INTO users ([entity-id], [clicks.0.value], [clicks.0.date], [clicks.1.value], [clicks.1.date], [clicks.2.value], [clicks.2.date], name, age) VALUES ("UUID-01", "Add to Cart", "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}", "Pay Now", "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}", "Support", "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}", "Jeff", 25);
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO users ([entity-id], [clicks.0.value], [clicks.0.date], [clicks.1.value], [clicks.1.date], [clicks.2.value], [clicks.2.date], name, age) VALUES ("UUID-01", "Add to Cart", "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}", "Pay Now", "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}", "Support", "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}", "Jeff", 25);'
curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "UUID-01": {
            "dimension": "users",
            "name": "Jeff",
            "age": 25,
            "clicks": [
                {
                    "value": "Add to Cart",
                    "date": "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}"
                }, {
                    "value": "Pay Now",
                    "date": "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}"
                }, {
                    "value": "Support",
                    "date": "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}"
                }
            ]
        },
        "auto-create": ["dimension", "column"]
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

insert_data = {
    "UUID-01": {
        "dimension": "users",
        "age": 25,
        "name": "Jeff",
        "clicks": [
            {
                "date": "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                "value": "Add to Cart"
            }, 
            {
                "date": "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                "value": "Pay Now"
            }, 
            {
                "date": "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                "value": "Support"
            }
        ]
    },
    "auto-create": [
        "dimension", 
        "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("dimension", "users")
            .put("age", 25)
            .put("name", "Jeff")
            .put("clicks", new JSONArray()
                .put(new JSONObject()
                    .put("date", "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}")
                    .put("value", "Add to Cart"))
                .put(new JSONObject()
                    .put("date", "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}")
                    .put("value", "Pay Now"))
                .put(new JSONObject()
                    .put("date", "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}")
                    .put("value", "Support"))))
        .put("auto-create", new JSONArray()
            .put("dimension")
            .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" => {
        "dimension" => "users",
        "age" => 25,
        "name" => "Jeff",
        "clicks" => [
            {
                "date" => "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                "value" => "Add to Cart"
            }, 
            {
                "date" => "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                "value" => "Pay Now"
            }, 
            {
                "date" => "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                "value" => "Support"
            }
        ]
    },
    "auto-create" => [
        "dimension", 
        "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": {
        "dimension": "users",
        "age": 25,
        "name": "Jeff",
        "clicks": [
            {
                "date": "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                "value": "Add to Cart"
            }, 
            {
                "date": "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                "value": "Pay Now"
            }, 
            {
                "date": "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                "value": "Support"
            }
        ]
    },
    "auto-create": [
        "dimension", 
        "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(
        "dimension" => "users",
        "age" => 25,
        "name" => "Jeff",
        "clicks" => array(
            array(
                "date" => "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                "value" => "Add to Cart"
            ), 
            array(
                "date" => "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                "value" => "Pay Now"
            ), 
            array(
                "date" => "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                "value" => "Support"
            )
        )
    ),
    "auto-create" => array(
        "dimension", 
        "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>{
                    {"dimension", "users"},
                    {"age", 25},
                    {"name", "Jeff"},
                    {"clicks", new List<dynamic>{
                        new Dictionary<string, dynamic>{
                            {"date", "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}"},
                            {"value", "Add to Cart"}
                        }, 
                        new Dictionary<string, dynamic>{
                            {"date", "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}"},
                            {"value", "Pay Now"}
                        }, 
                        new Dictionary<string, dynamic>{
                            {"date", "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}"},
                            {"value", "Support"}
                        }
                    }}
                }},
                {"auto-create", new List<dynamic>{
                    "dimension", 
                    "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{}{
            "dimension": "users",
            "age": 25,
            "name": "Jeff",
            "clicks": []interface{}{
                map[string]interface{}{
                    "date": "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                    "value": "Add to Cart",
                },
                map[string]interface{}{
                    "date": "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                    "value": "Pay Now",
                },
                map[string]interface{}{
                    "date": "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                    "value": "Support",
                },
            },
        },
        "auto-create": []interface{}{
            "dimension",
            "column",
        },
    }

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

Updating a value

Below is an update example where we will update a single record using the entity-id as the selector to update the name to Mary.

UPDATE users SET name = 'Mary' WHERE [entity-id] = 'UUID-01';
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'UPDATE users SET name = 'Mary' WHERE [entity-id] = 'UUID-01';'
curl -X POST https://api.slicingdice.com/v1/update \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
   "dimension":"users",
   "query":[
      {
         "entity-id":{
            "equals":"UUID-01"
         }
      }
   ],
   "set":{
      "name":"Mary"
   }
}'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

update_data = {
    "query": [
        {
            "entity-id": {
                "equals": "UUID-01"
            }
        }
    ],
    "set": {
        "name": "Mary"
    },
    "dimension": "users"
}

print(slicingdice.update(update_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");

        JSONObject updateData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("entity-id", new JSONObject()
                    .put("equals", "UUID-01"))))
        .put("set", new JSONObject()
            .put("name", "Mary"))
        .put("dimension", "users");

        JSONObject result = slicingdice.update(updateData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

update_data = {
    "query" => [
        {
            "entity-id" => {
                "equals" => "UUID-01"
            }
        }
    ],
    "set" => {
        "name" => "Mary"
    },
    "dimension" => "users"
}

puts slicingdice.update(update_data)
const SlicingDice = require('slicerjs');

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

const updateData = {
    "query": [
        {
            "entity-id": {
                "equals": "UUID-01"
            }
        }
    ],
    "set": {
        "name": "Mary"
    },
    "dimension": "users"
};

slicingdice.update(updateData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});
<?php
use Slicer\SlicingDice;

$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$updateData = array(
    "query" => array(
        array(
            "entity-id" => array(
                "equals" => "UUID-01"
            )
        )
    ),
    "set" => array(
        "name" => "Mary"
    ),
    "dimension" => "users"
);

print_r($slicingdice->update($updateData));
?>
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");

            var updateData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"entity-id", new Dictionary<string, dynamic>{
                            {"equals", "UUID-01"}
                        }}
                    }
                }},
                {"set", new Dictionary<string, dynamic>{
                    {"name", "Mary"}
                }},
                {"dimension", "users"}
            };

            var result = slicingdice.Update(updateData);
            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)

    updateData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "entity-id": map[string]interface{}{
                    "equals": "UUID-01",
                },
            },
        },
        "set": map[string]interface{}{
            "name": "Mary",
        },
        "dimension": "users",
    }

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

Deleting a value

You can also delete a value from a specific column on desired records, to do this you simply need to set the value to null on the column. On the below example we will delete the value for the age column on every record that has the name John.

UPDATE users SET age = NULL WHERE name = 'John';
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'UPDATE users SET age = NULL WHERE name = 'John';'
curl -X POST https://api.slicingdice.com/v1/update \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
   "dimension":"users",
   "query":[
      {
         "name":{
            "equals":"John"
         }
      }
   ],
   "set":{
      "age":null
   }
}'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

update_data = {
    "query": [
        {
            "name": {
                "equals": "John"
            }
        }
    ],
    "set": {
        "age": None
    },
    "dimension": "users"
}

print(slicingdice.update(update_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");

        JSONObject updateData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("name", new JSONObject()
                    .put("equals", "John"))))
        .put("set", new JSONObject()
            .put("age", null))
        .put("dimension", "users");

        JSONObject result = slicingdice.update(updateData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

update_data = {
    "query" => [
        {
            "name" => {
                "equals" => "John"
            }
        }
    ],
    "set" => {
        "age" => nil
    },
    "dimension" => "users"
}

puts slicingdice.update(update_data)
const SlicingDice = require('slicerjs');

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

const updateData = {
    "query": [
        {
            "name": {
                "equals": "John"
            }
        }
    ],
    "set": {
        "age": None
    },
    "dimension": "users"
};

slicingdice.update(updateData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});
<?php
use Slicer\SlicingDice;

$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$updateData = array(
    "query" => array(
        array(
            "name" => array(
                "equals" => "John"
            )
        )
    ),
    "set" => array(
        "age" => NULLL
    ),
    "dimension" => "users"
);

print_r($slicingdice->update($updateData));
?>
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");

            var updateData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"name", new Dictionary<string, dynamic>{
                            {"equals", "John"}
                        }}
                    }
                }},
                {"set", new Dictionary<string, dynamic>{
                    {"age", null}
                }},
                {"dimension", "users"}
            };

            var result = slicingdice.Update(updateData);
            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)

    updateData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "name": map[string]interface{}{
                    "equals": "John",
                },
            },
        },
        "set": map[string]interface{}{
            "age": nil,
        },
        "dimension": "users",
    }

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

Deleting data

We will use the data below during the delete examples.

Entities
Name
Age
Clicks

UUID-01

Jeff

25

Add to Cart - {% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}
Pay Now - {% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}
Support - {% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}

INSERT INTO users ([entity-id], [clicks.0.value], [clicks.0.date], [clicks.1.value], [clicks.1.date], [clicks.2.value], [clicks.2.date], name, age) VALUES ("UUID-01", "Add to Cart", "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}", "Pay Now", "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}", "Support", "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}", "Jeff", 25);
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'INSERT INTO users ([entity-id], [clicks.0.value], [clicks.0.date], [clicks.1.value], [clicks.1.date], [clicks.2.value], [clicks.2.date], name, age) VALUES ("UUID-01", "Add to Cart", "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}", "Pay Now", "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}", "Support", "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}", "Jeff", 25);'
curl -X POST https://api.slicingdice.com/v1/insert \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
        "UUID-01": {
            "dimension": "users",
            "name": "Jeff",
            "age": 25,
            "clicks": [
                {
                    "value": "Add to Cart",
                    "date": "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}"
                }, {
                    "value": "Pay Now",
                    "date": "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}"
                }, {
                    "value": "Support",
                    "date": "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}"
                }
            ]
        },
        "auto-create": ["dimension", "column"]
    }'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY', uses_test_endpoint=True)

insert_data = {
    "UUID-01": {
        "dimension": "users",
        "age": 25,
        "name": "Jeff",
        "clicks": [
            {
                "date": "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                "value": "Add to Cart"
            }, 
            {
                "date": "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                "value": "Pay Now"
            }, 
            {
                "date": "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                "value": "Support"
            }
        ]
    },
    "auto-create": [
        "dimension", 
        "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("dimension", "users")
            .put("age", 25)
            .put("name", "Jeff")
            .put("clicks", new JSONArray()
                .put(new JSONObject()
                    .put("date", "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}")
                    .put("value", "Add to Cart"))
                .put(new JSONObject()
                    .put("date", "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}")
                    .put("value", "Pay Now"))
                .put(new JSONObject()
                    .put("date", "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}")
                    .put("value", "Support"))))
        .put("auto-create", new JSONArray()
            .put("dimension")
            .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" => {
        "dimension" => "users",
        "age" => 25,
        "name" => "Jeff",
        "clicks" => [
            {
                "date" => "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                "value" => "Add to Cart"
            }, 
            {
                "date" => "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                "value" => "Pay Now"
            }, 
            {
                "date" => "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                "value" => "Support"
            }
        ]
    },
    "auto-create" => [
        "dimension", 
        "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": {
        "dimension": "users",
        "age": 25,
        "name": "Jeff",
        "clicks": [
            {
                "date": "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                "value": "Add to Cart"
            }, 
            {
                "date": "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                "value": "Pay Now"
            }, 
            {
                "date": "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                "value": "Support"
            }
        ]
    },
    "auto-create": [
        "dimension", 
        "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(
        "dimension" => "users",
        "age" => 25,
        "name" => "Jeff",
        "clicks" => array(
            array(
                "date" => "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                "value" => "Add to Cart"
            ), 
            array(
                "date" => "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                "value" => "Pay Now"
            ), 
            array(
                "date" => "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                "value" => "Support"
            )
        )
    ),
    "auto-create" => array(
        "dimension", 
        "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>{
                    {"dimension", "users"},
                    {"age", 25},
                    {"name", "Jeff"},
                    {"clicks", new List<dynamic>{
                        new Dictionary<string, dynamic>{
                            {"date", "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}"},
                            {"value", "Add to Cart"}
                        }, 
                        new Dictionary<string, dynamic>{
                            {"date", "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}"},
                            {"value", "Pay Now"}
                        }, 
                        new Dictionary<string, dynamic>{
                            {"date", "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}"},
                            {"value", "Support"}
                        }
                    }}
                }},
                {"auto-create", new List<dynamic>{
                    "dimension", 
                    "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{}{
            "dimension": "users",
            "age": 25,
            "name": "Jeff",
            "clicks": []interface{}{
                map[string]interface{}{
                    "date": "{% convert_date 'YYYY-MM-DDT12:54:12Z' '-10d' %}",
                    "value": "Add to Cart",
                },
                map[string]interface{}{
                    "date": "{% convert_date 'YYYY-MM-DDT10:22:10Z' '-5d' %}",
                    "value": "Pay Now",
                },
                map[string]interface{}{
                    "date": "{% convert_date 'YYYY-MM-DDT17:05:25Z' '-2d' %}",
                    "value": "Support",
                },
            },
        },
        "auto-create": []interface{}{
            "dimension",
            "column",
        },
    }

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

Deleting a single record

Below is a deletion example where we will delete a single record using the entity-id as the selector.

DELETE FROM users WHERE [entity-id] = 'UUID-01';
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'DELETE FROM users WHERE [entity-id] = 'UUID-01';'
curl -X POST https://api.slicingdice.com/v1/delete \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
   "dimension":"users",
   "query":[
      {
         "entity-id":{
            "equals":"UUID-01"
         }
      }
   ]
}'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

delete_data = {
    "query": [
        {
            "entity-id": {
                "equals": "UUID-01"
            }
        }
    ],
    "dimension": "users"
}

print(slicingdice.delete(delete_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");

        JSONObject deleteData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("entity-id", new JSONObject()
                    .put("equals", "UUID-01"))))
        .put("dimension", "users");

        JSONObject result = slicingdice.delete(deleteData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

delete_data = {
    "query" => [
        {
            "entity-id" => {
                "equals" => "UUID-01"
            }
        }
    ],
    "dimension" => "users"
}

puts slicingdice.delete(delete_data)
const SlicingDice = require('slicerjs');

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

const deleteData = {
    "query": [
        {
            "entity-id": {
                "equals": "UUID-01"
            }
        }
    ],
    "dimension": "users"
};

slicingdice.delete(deleteData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});
<?php
use Slicer\SlicingDice;

$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$deleteData = array(
    "query" => array(
        array(
            "entity-id" => array(
                "equals" => "UUID-01"
            )
        )
    ),
    "dimension" => "users"
);

print_r($slicingdice->delete($deleteData));
?>
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");

            var deleteData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"entity-id", new Dictionary<string, dynamic>{
                            {"equals", "UUID-01"}
                        }}
                    }
                }},
                {"dimension", "users"}
            };

            var result = slicingdice.Delete(deleteData);
            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)

    deleteData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "entity-id": map[string]interface{}{
                    "equals": "UUID-01",
                },
            },
        },
        "dimension": "users",
    }

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

Deleting multiple records

You can also delete multiple records a time, to do so you need to use a query that selects many records at a time as the example below, which we will delete all the records that have age 25.

DELETE FROM users WHERE age = 25;
$ curl -X POST https://api.slicingdice.com/v1/sql \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/sql' \
    -d 'DELETE FROM users WHERE age = 25;'
curl -X POST https://api.slicingdice.com/v1/delete \
    -H 'Authorization: MASTER_OR_WRITE_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
   "dimension":"users",
   "query":[
      {
         "age":{
            "equals":25
         }
      }
   ]
}'
from pyslicer import SlicingDice
slicingdice = SlicingDice(master_key='MASTER_API_KEY')

delete_data = {
    "query": [
        {
            "age": {
                "equals": 25
            }
        }
    ],
    "dimension": "users"
}

print(slicingdice.delete(delete_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");

        JSONObject deleteData = new JSONObject()
        .put("query", new JSONArray()
            .put(new JSONObject()
                .put("age", new JSONObject()
                    .put("equals", 25))))
        .put("dimension", "users");

        JSONObject result = slicingdice.delete(deleteData);
        System.out.println(result.toString());
    }
}
require 'rbslicer'
slicingdice = SlicingDice.new(master_key: 'MASTER_API_KEY')

delete_data = {
    "query" => [
        {
            "age" => {
                "equals" => 25
            }
        }
    ],
    "dimension" => "users"
}

puts slicingdice.delete(delete_data)
const SlicingDice = require('slicerjs');

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

const deleteData = {
    "query": [
        {
            "age": {
                "equals": 25
            }
        }
    ],
    "dimension": "users"
};

slicingdice.delete(deleteData).then((resp) => {
    console.log(resp);
}, (err) => {
    console.error(err);
});
<?php
use Slicer\SlicingDice;

$slicingdice = new SlicingDice(array("masterKey" => "MASTER_API_KEY"));

$deleteData = array(
    "query" => array(
        array(
            "age" => array(
                "equals" => 25
            )
        )
    ),
    "dimension" => "users"
);

print_r($slicingdice->delete($deleteData));
?>
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");

            var deleteData = new Dictionary<string, dynamic>{
                {"query", new List<dynamic>{
                    new Dictionary<string, dynamic>{
                        {"age", new Dictionary<string, dynamic>{
                            {"equals", 25}
                        }}
                    }
                }},
                {"dimension", "users"}
            };

            var result = slicingdice.Delete(deleteData);
            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)

    deleteData := map[string]interface{}{
        "query": []interface{}{
            map[string]interface{}{
                "age": map[string]interface{}{
                    "equals": 25,
                },
            },
        },
        "dimension": "users",
    }

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