Skip to content

Latest commit

 

History

History
234 lines (149 loc) · 5.93 KB

Example.md

File metadata and controls

234 lines (149 loc) · 5.93 KB

e3db-core --- Platform agnostic e3db client kernel

CLI Example

How to Build with Makefile

To build a local version of the command-line interface, check out the sources locally, install dependencies Run the following command to build an executable

git clone https://github.com/tozny/e3db-core
make all

Debug Build

For a debug build with Address Sanitizer enabled:

make debug

The debug build uses Address Sanitizer, a fast memory error detector. It's useful for detecting memory access issues in the code, such as buffer overflows, use-after-free, and memory leaks.

How to Clean and Build

To clean and build the project:

make clean all

For a clean debug build:

make clean debug

How to Run

To run the following library

./build/e3db [command]

Write Record

Write record takes 3 parameters, -r takes the record type for the record, -d takes the data meant to be encrypted for the record, and -m takes the plain meta fields used for advanced searching

# Run write record with client configuration file found in ~/.tozny/e3db.json and the record data/meta found in a file
./build/e3db write-record -t recordTypeWanted -d @<PathToJSON>/examples/example_data.json  -m @<PathToJSON>/examples/example_meta.json

# Run write record with custom config file path and the record data/meta found in a file
./build/e3db write-record -t recordTypeWanted -d @<PathToJSON>/examples/example_data.json  -m @<PathToJSON>/examples/example_meta.json -c @<PathToJSON>/examples/config.json

# Run write record with client configuration file found in ~/.tozny/e3db.json and the record data/meta JSON blobs
./build/e3db write-record -t recordTypeWanted -d '{"key": "value"}'  -m '{"key": "value"}'

# Run write record with custom config file path and the record data/meta JSON blobs
./build/e3db write-record  -c @<PathToJSON>/examples/config.json -t recordTypeWanted -d '{"key": "value"}'  -m '{"key": "value"}'

Read Record

Read record takes a space separated list of record ids to fetch

# Run read record with client configuration file found in ~/.tozny/e3db.json
./build/e3db read-record 4d289c9d-ffe4-45a9-a423-c8fdcf76ddd1

# Run read record with custom config file path 
./build/e3db read-record -c @<PathToJSON>/examples/config.json 4d289c9d-ffe4-45a9-a423-c8fdcf76ddd1

# Run read record with multiple records 
./build/e3db read-record 4d289c9d-ffe4-45a9-a423-c8fdcf76ddd1 b8a79ca6-c1c2-4bc4-9906-739e772ae110

# Run read record with custom config file path and multiple records
./build/e3db read-record -c @<PathToJSON>/examples/config.json 4d289c9d-ffe4-45a9-a423-c8fdcf76ddd1 b8a79ca6-c1c2-4bc4-9906-739e772ae110

How to Build with CMake

To build a local version of the command-line interface, check out the sources locally, install dependencies Run the following command to build an executable

git clone https://github.com/tozny/e3db-core
mkdir build
cd build
cmake ..
make

How to Clean

To clean the project:

make clean 

How to Run

To run the following library from the build directory

./cmd/e3db [command]

Write Record

Write record takes 3 parameters, -r takes the record type for the record, -d takes the data meant to be encrypted for the record, and -m takes the plain meta fields used for advanced searching

# Run write record with client configuration file found in ~/.tozny/e3db.json and the record data/meta found in a file
./cmd/e3db write-record -t recordTypeWanted -d @<PathToJSON>/examples/example_data.json  -m @<PathToJSON>/examples/example_meta.json

# Run write record with custom config file path and the record data/meta found in a file
./cmd/e3db write-record -t recordTypeWanted -d @<PathToJSON>/examples/example_data.json  -m @<PathToJSON>/examples/example_meta.json -c @<PathToJSON>/examples/config.json

# Run write record with client configuration file found in ~/.tozny/e3db.json and the record data/meta JSON blobs
./cmd/e3db write-record -t recordTypeWanted -d '{"key": "value"}'  -m '{"key": "value"}'

# Run write record with custom config file path and the record data/meta JSON blobs
./cmd/e3db write-record  -c @<PathToJSON>/examples/config.json -t recordTypeWanted -d '{"key": "value"}'  -m '{"key": "value"}'

Read Record

Read record takes a space separated list of record ids to fetch

# Run read record with client configuration file found in ~/.tozny/e3db.json
./cmd/e3db read-record 4d289c9d-ffe4-45a9-a423-c8fdcf76ddd1

# Run read record with custom config file path 
./cmd/e3db read-record -c @<PathToJSON>/examples/config.json 4d289c9d-ffe4-45a9-a423-c8fdcf76ddd1

# Run read record with multiple records 
./cmd/e3db read-record 4d289c9d-ffe4-45a9-a423-c8fdcf76ddd1 b8a79ca6-c1c2-4bc4-9906-739e772ae110

# Run read record with custom config file path and multiple records
./cmd/e3db read-record -c @<PathToJSON>/examples/config.json 4d289c9d-ffe4-45a9-a423-c8fdcf76ddd1 b8a79ca6-c1c2-4bc4-9906-739e772ae110

Example Simple Program

Prerequisite

Must have a Tozny Client Configuration File Located @ ~/.tozny/e3db.json.

How to Build with Makefile

To build a small example project

git clone https://github.com/tozny/e3db-core
make simple

For a debug build of the simple project with Address Sanitizer enabled:

make debug-simple

How to Clean and Build Simple Project

To clean and build the simple project:

make clean simple

For a clean debug build of the simple project:

make clean debug-simple

How to Run

To run the following example project

./simple/simple 

How to Build with CMake

To build a small example project

git clone https://github.com/tozny/e3db-core
mkdir build
cd build
cmake ..
make

How to Clean

To clean the simple project:

make clean 

How to Run

To run the following example project from the top level directory

mkdir build
cd build
cmake ..
make
./examples/simple