ObjectBox C and C++: super-fast database for objects and structs

Overview

ObjectBox Embedded Database for C and C++

ObjectBox is a superfast C and C++ database for embedded devices (mobile and IoT), desktop and server apps. The out-of-the-box Data Sync keeps data in sync across devices and any kind of backend/cloud reliably for occasionally connected devices. ObjectBox Data Persistence and Data Sync follows an offline-first approach and can be used on-premise as well as with a cloud setup.

This is the ObjectBox runtime library to run ObjectBox as an embedded database in your C or C++ application.

Here's a C++ example that inserts a Task data object (a plain user defined struct) into the database:

obx::Box<Task> box(store);
box.put({.text = "Buy milk"}); 

See ObjectBox C and C++ docs for API details.

Latest version: 0.15.0 (2021-12-09). See changelog for more details.

Feature Highlights

🏁 High performance on restricted devices, like IoT gateways, micro controllers, ECUs etc.
🪂 Resourceful with minimal CPU, power and Memory usage for maximum flexibility and sustainability
🔗 Relations: object links / relationships are built-in
💻 Multiplatform: Linux, Windows, Android, iOS, macOS

🌱 Scalable: handling millions of objects resource-efficiently with ease
💐 Queries: filter data as needed, even across relations
🦮 Statically typed: compile time checks & optimizations
📃 Automatic schema migrations: no update scripts needed

And much more than just data persistence
👥 ObjectBox Sync: keeps data in sync between devices and servers
🕒 ObjectBox TS: time series extension for time based data

Some more technical details:

  • Zero-copy reads for highest possible performance; access tens of millions of objects on commodity hardware
  • Lightweight for smart devices; its binary size is only around 1 MB
  • Direct support for FlatBuffers data objects (aka "flatbuffers table")
  • Flex type to represent any FlexBuffers
  • Secondary indexes based on object properties
  • Async API for asynchronous puts, inserts, updates, removes
  • Optimized for time series data (TS edition only)
  • Data synchronization across the network (sync edition only)

Usage and Installation

In most cases you want to use the C and C++ APIs in combination with the ObjectBox Generator tool. This way, you get a convenient C or C++ API which requires minimal code on your side to work with the database.

The APIs come as single header file for C and C++:

Compile your code against it and use the binary library (.so, .dylib, .dll depending on the platform) to link against. Head over to ObjectBox C and C++ installation docs for step-by-step instructions.

C++ API

The C++ API is built on top of the C API exposed by the library (e.g. you still need objectbox.h). You can also use both APIs from your code if necessary. For example, you use the C++ obx::Box class for most database operations, but "break out" into the C API for a special function you need.
Note that to use the obx::Box class, you also need the ObjectBox Generator to generate binding code. Find more details how to use it the Getting started section of the docs.

Examples

Have a look at the following TaskList example apps, depending on your programming language and preference:

Documentation

Current state / Changelog

The C API is a thin wrapper around a robust DB core, which is version 3.x and already used on millions of devices.

Beta notice: the C API will become stable starting from version 1.0. Until then, API improvements may result in breaking changes. For example, functions may still be renamed.

Changelog: If you update from a previous version, please check the changelog. Besides new features, there may be breaking changes requiring modifications to your code.

Supported platforms:

  • Linux 64-bit
  • Linux ARMv6hf (e.g. Raspberry PI Zero)
  • Linux ARMv7hf (e.g. Raspberry PI 3/4)
  • Linux ARMv8/AArch64 (e.g. Raspberry PI 3/4 with a 64 bit OS like Ubuntu)
  • MacOS 64-bit
  • Windows 32-bit
  • Windows 64-bit

C API as the Foundation for Higher Languages

The plain C API (without the Generator) also serves as a basis for ObjectBox bindings in higher languages. For example, the official APIs for Go, Swift, Dart/Flutter and Python rely on the C API. In the same way, you could create an ObjectBox API for another programming language, e.g. for JavaScript. For the C API, data consists of bytes representing FlatBuffers tables, which you can build and read in your language of choice.

Other languages/bindings

ObjectBox supports multiple platforms and languages. Besides C/C++, ObjectBox also offers:

How I help ObjectBox?

Let us know what you love, what you don’t, what do you want to see next?

We're looking forward to receiving your comments and requests:

  • Add GitHub issues
  • Upvote issues you find important by hitting the 👍 /+1 reaction button
  • Drop us a line via @ObjectBox_io
  • us, if you like what you see

Thank you! 🙏

Keep in touch: For general news on ObjectBox, check our blog!

License

Copyright 2018-2021 ObjectBox Ltd. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Issues
  • support  Apple M1 Silicon

    support Apple M1 Silicon

    bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh)

    Base config: OS Darwin and arch arm64 Adjusted OS to Macos Using configuration Macos::arm64 Error: the platform configuration Macos::arm64 is unsupported. You can select the configuration manually (use --help for details) Possible values are:

    • Linux::x86_64
    • Linux::armv6
    • Linux::armv7
    • Linux::armv8
    • Windows::x86
    • Windows::x86_64
    • Macos::x86_64
    enhancement 
    opened by jochendev 15
  • to-one and to-many relations

    to-one and to-many relations

    Hi, Unfortunately, there is no explanation about relations in ObjectBox documentation for c++ . Please explain how we should use to-one and to-many relations in ObjectBox c++ ? Thanks

    enhancement 
    opened by mohammadjalalis 4
  • error:no matching function for call to 'obx::Box<Task>::put(<brace-enclosed initializer list>)

    error:no matching function for call to 'obx::Box::put()

    when I compile the example by running: g++ main.cpp -I. -std=c++11 -lobjectbox error:no matching function for call to 'obx::Box::put()

    obx_id id = box.put({.text = "Buy milk"}) ^

    int main() { obx::Store store(create_obx_model()); obx::Box box(store);

    obx_id id = box.put({.text = "Buy milk"});  //  error code
    

    std::unique_ptr task = box.get(id); // Read if (task) { task->text += " & some bread"; box.put(*task); // Update box.remove(id); // Delete } return 0; }

    opened by Laganer 3
  • Prebuilt Libraries for Android

    Prebuilt Libraries for Android

    Hi, I am working on an Android NDK project which will use objectbox-c. Can you provide prebuilt libraries for Android as well in addition to the following?

    • Linux::x86_64
    • Linux::armv6
    • Linux::armv7
    • Windows::x86
    • Windows::x86_64
    • Macos::x86_64
    opened by ashtondchen 3
  • 'Skipped low-level close of cursor' after re-creating transaction

    'Skipped low-level close of cursor' after re-creating transaction

    If I re-create transaction for same table right after previous is closed, I always get warning [WARN ] Skipped low-level close of cursor (write, TX #xxx alive). Imagine there is following code:

    auto txn = obx_txn_begin(store);
    auto cursor = obx_cursor_create(txn, 1);
    obx_cursor_put(cursor, <something>);
    obx_cursor_close(cursor);
    obx_txn_close(txn);
    txn = obx_txn_begin(store);
    cursor = obx_cursor_create(txn, 1);
    

    I will produce this warning unless there will be timeout before starting second transaction. I believe there should be convenience function to wait for transaction is completed for this case.

    opened by snakelizzard 2
  • How to make a many-to-many relation in fsb file and objectbox-generator for c++?

    How to make a many-to-many relation in fsb file and objectbox-generator for c++?

    This is my database.fsb file

    table Author {
        /// objectbox:id
        id:ulong;
        text:string;
    }
    
    table Book{
        /// objectbox:id
        id: ulong;
        name: string;
    
        /// objectbox:relation(name=authors,to=Author)
        authors:ulong;
    }
    

    What type I must use for authors in Book table to make a many-to-many relation between book and authors?

    question 
    opened by Mr17MG 1
  • BoAT-X Framework for XinYi-XY1100 Integration Guideline-Missing Spaces, wrong format

    BoAT-X Framework for XinYi-XY1100 Integration Guideline-Missing Spaces, wrong format

    1. Build the demo program of XY1100, generate. bin file for download Better add Space notation after the word "generate" So the sentence will be look like

    2. Build the demo program of XY1100, generate .bin file for download

    bug 
    opened by mia-BoAT-Mariner 1
  • BoAT-X Framework for XinYi-XY1100 Integration Guideline-Files Modification-inaccurate words

    BoAT-X Framework for XinYi-XY1100 Integration Guideline-Files Modification-inaccurate words

    Chinese version:

    在XinYi-XY1100平台中增加BoAT-X-Framework的功能支持选项

    English version: Increase the function support option of BoAT-X-Framework in XinYi-XY1100 platform

    Here better use "add" rather than "increase"

    Kindly suggest to change to Add a new option to support BoAT-X-Framework in XinYi-XY1100 platform

    bug 
    opened by mia-BoAT-Mariner 1
  • tasklist.fbs with/without :sync

    tasklist.fbs with/without :sync

    This example has 2 apps, one without sync and another with sync. This file is currently being shared in the examples/cpp-gen folder. But, with this: "/// objectbox:sync" directive it can't be used on the main.cpp (without sync) example. We must separate the folders (examples/cpp-gen-no-sync, examples/cpp-gen-sync) or generate specific .fbs file on the CMakeLists.txt

    opened by marciojtjr 1
  • Could not open database environment; please check options and file system

    Could not open database environment; please check options and file system

    Describe the bug Could not create ObjectBox - please check configuration: Could not open database environment; please check options and file system (13) [recovered]

    Basic info (please complete the following information):

    • ObjectBox version: [latest version]
    • C or C++ version: [unknown]
    • Reproducibility: [always]
    • OS: [Window10]

    To Reproduce Steps to reproduce the behavior: go test

    Expected behavior

    Code Logs, stack traces

    panic: Could not create ObjectBox - please check configuration: Could not open database environment; please check options and file system (13) [recovered]
            panic: Could not create ObjectBox - please check configuration: Could not open database environment; please check options and file system (13)
    
    goroutine 51 [running]:
    testing.tRunner.func1(0xc00012e700)
            /usr/lib/go-1.13/src/testing/testing.go:874 +0x3a3
    panic(0x665820, 0xc000200540)
            /usr/lib/go-1.13/src/runtime/panic.go:679 +0x1b2
    github.com/objectbox/objectbox-go/objectbox.(*Builder).Build(0xc00021c4c0, 0xc0002047e0, 0xc00021c4c0, 0x0)
            /home/ihbing/go/pkg/mod/github.com/objectbox/[email protected]/objectbox/builder.go:133 +0xdc
    souobjectboxparser/objectboxparser.initObjectBox(0xc00012b600, 0x12, 0xc000220000)
            /mnt/f/task/soul/src/souobjectboxparser/objectboxparser/objectboxparser.go:66 +0xa6
    souobjectboxparser/objectboxparser.ParseMDBData(0xc000220000, 0x1d000, 0x1d200, 0x0, 0x0)
            /mnt/f/task/soul/src/souobjectboxparser/objectboxparser/objectboxparser.go:34 +0x158
    souobjectboxparser/objectboxparser.Start()
            /mnt/f/task/soul/src/souobjectboxparser/objectboxparser/objectboxparser.go:17 +0xc5
    souobjectboxparser/objectboxparser.TestStart(0xc00012e700)
            /mnt/f/task/soul/src/souobjectboxparser/objectboxparser/objectboxparser_test.go:6 +0x20
    testing.tRunner(0xc00012e700, 0x6e7ee0)
            /usr/lib/go-1.13/src/testing/testing.go:909 +0xc9
    created by testing.(*T).Run
            /usr/lib/go-1.13/src/testing/testing.go:960 +0x350
    exit status 2
    
    

    Additional context

    bug 
    opened by Humenger 1
  • Readme has wrong link for generated C

    Readme has wrong link for generated C

    The readme file Examples section has this link text:

    C, with generated code - plain C, using code generated by objectbox-generator

    But it links to the cpp-gen/ directory instead of the c-gen/ directory.

    documentation 
    opened by superchalupa 1
  • Better docs

    Better docs

    Hi,

    I think that you can improve the docs with these topics:

    1. More complete and complex examples
    2. Relation one-to-many
    3. Relation one-to-one
    4. Storing date/time
    5. Storing float/double
    6. More complex queries (the examples in docs are too simple)
    7. About indexes (if exists)
    8. Full text-search
    9. Queries with date/time
    10. Date/time are stored as UTC timestamp?
    11. How to work with Multi-thread?
    12. Recovery after corruption file (it exists?)

    Thanks.

    enhancement 
    opened by paulocoutinhox 0
  • Conan package manager support

    Conan package manager support

    Hi,

    Please, add conan package manager support.

    I open an issue/request there: https://github.com/conan-io/conan-center-index/issues/11235

    It will open the doors to we use on our projects like a dependency.

    Thanks.

    enhancement 
    opened by paulocoutinhox 3
  • Clarification on Android/iOS use

    Clarification on Android/iOS use

    I'd love to use ObjectBox in a multi-platform Android/iOS app (C++, QT/QML stack), as it looks to be pretty much perfect for my use case. But. It is unclear to me if that is supported - the main library/project says that it is, but the C/C++ wrapper does not mention so, and there are no binaries on the releases page for Android or iOS.

    There's https://github.com/objectbox/objectbox-c/issues/4, but in the replies, it is not clear to me what "Android APIs also include the C interface" means. Am I supposed to get the Java jars from the gradle repository, and those would expose the C interface?

    So effectively, this is both a question, as well as a request for clarification in the readme/releases if ObjectBox can be used from Android and iOS. If yes, then a tutorial/tips on how to do so, would be very much appreciated.

    enhancement 
    opened by Dreamykass 12
  • support armv7 (not armv7hf)

    support armv7 (not armv7hf)

    Hello, objectbox: We have a device that not support hard-float, but we really want to use objectbox. Can you please provide shared library or static library for armv7? Thank you very much. ( The chip on our device is Hi3516, and the system is linux.

    enhancement 
    opened by whichname 1
Releases(v0.17.0)
Owner
ObjectBox
ObjectBox object oriented database - up to 10x faster than SQLite
ObjectBox
MySQL Server, the world's most popular open source database, and MySQL Cluster, a real-time, open source transactional database.

Copyright (c) 2000, 2021, Oracle and/or its affiliates. This is a release of MySQL, an SQL database server. License information can be found in the

MySQL 8k Jul 4, 2022
A mini database for learning database

A mini database for learning database

Chuckie Tan 3 Nov 3, 2021
GridDB is a next-generation open source database that makes time series IoT and big data fast,and easy.

Overview GridDB is Database for IoT with both NoSQL interface and SQL Interface. Please refer to GridDB Features Reference for functionality. This rep

GridDB 1.8k Jun 27, 2022
Nebula Graph is a distributed, fast open-source graph database featuring horizontal scalability and high availability

Nebula Graph is an open-source graph database capable of hosting super large scale graphs with dozens of billions of vertices (nodes) and trillions of edges, with milliseconds of latency.

vesoft inc. 807 Jun 30, 2022
A very fast lightweight embedded database engine with a built-in query language.

upscaledb 2.2.1 Fr 10. Mär 21:33:03 CET 2017 (C) Christoph Rupp, [email protected]; http://www.upscaledb.com This is t

Christoph Rupp 531 Jun 20, 2022
libmdbx is an extremely fast, compact, powerful, embedded, transactional key-value database, with permissive license

One of the fastest embeddable key-value ACID database without WAL. libmdbx surpasses the legendary LMDB in terms of reliability, features and performance.

Леонид Юрьев (Leonid Yuriev) 1k Apr 13, 2022
A friendly and lightweight C++ database library for MySQL, PostgreSQL, SQLite and ODBC.

QTL QTL is a C ++ library for accessing SQL databases and currently supports MySQL, SQLite, PostgreSQL and ODBC. QTL is a lightweight library that con

null 155 Jun 26, 2022
dqlite is a C library that implements an embeddable and replicated SQL database engine with high-availability and automatic failover

dqlite dqlite is a C library that implements an embeddable and replicated SQL database engine with high-availability and automatic failover. The acron

Canonical 3k Jun 27, 2022
ESE is an embedded / ISAM-based database engine, that provides rudimentary table and indexed access.

Extensible-Storage-Engine A Non-SQL Database Engine The Extensible Storage Engine (ESE) is one of those rare codebases having proven to have a more th

Microsoft 780 Jun 13, 2022
OceanBase is an enterprise distributed relational database with high availability, high performance, horizontal scalability, and compatibility with SQL standards.

What is OceanBase database OceanBase Database is a native distributed relational database. It is developed entirely by Alibaba and Ant Group. OceanBas

OceanBase 4.4k Jun 27, 2022
StarRocks is a next-gen sub-second MPP database for full analysis senarios, including multi-dimensional analytics, real-time analytics and ad-hoc query, formerly known as DorisDB.

StarRocks is a next-gen sub-second MPP database for full analysis senarios, including multi-dimensional analytics, real-time analytics and ad-hoc query, formerly known as DorisDB.

StarRocks 2.7k Jun 26, 2022
Velox is a new C++ vectorized database acceleration library aimed to optimizing query engines and data processing systems.

Velox is a C++ database acceleration library which provides reusable, extensible, and high-performance data processing components

Facebook Incubator 893 Jun 27, 2022
Config and tools for config of tasmota devices from mysql database

tasmota-sql Tools for management of tasmota devices based on mysql. The tasconfig command can load config from tasmota and store in sql, or load from

RevK 3 Jan 8, 2022
The database built for IoT streaming data storage and real-time stream processing.

The database built for IoT streaming data storage and real-time stream processing.

HStreamDB 501 Jun 29, 2022
Serverless SQLite database read from and write to Object Storage Service, run on FaaS platform.

serverless-sqlite Serverless SQLite database read from and write to Object Storage Service, run on FaaS platform. NOTES: This repository is still in t

老雷 7 May 12, 2022
Trilogy is a client library for MySQL-compatible database servers, designed for performance, flexibility, and ease of embedding.

Trilogy is a client library for MySQL-compatible database servers, designed for performance, flexibility, and ease of embedding.

GitHub 248 Jun 11, 2022
DB Browser for SQLite (DB4S) is a high quality, visual, open source tool to create, design, and edit database files compatible with SQLite.

DB Browser for SQLite What it is DB Browser for SQLite (DB4S) is a high quality, visual, open source tool to create, design, and edit database files c

null 16.7k Jun 27, 2022
DuckDB is an in-process SQL OLAP Database Management System

DuckDB is an in-process SQL OLAP Database Management System

DuckDB 5.4k Jun 27, 2022
YugabyteDB is a high-performance, cloud-native distributed SQL database that aims to support all PostgreSQL features

YugabyteDB is a high-performance, cloud-native distributed SQL database that aims to support all PostgreSQL features. It is best to fit for cloud-native OLTP (i.e. real-time, business-critical) applications that need absolute data correctness and require at least one of the following: scalability, high tolerance to failures, or globally-distributed deployments.

yugabyte 6.6k Jul 1, 2022