Convert Figma logo to code with AI

realm logorealm-core

Core database component for the Realm Mobile Database SDKs

1,012
155
1,012
268

Top Related Projects

6,288

Fast persistent recoverable log and key-value store + cache, in C# and C++.

FoundationDB - the open source, distributed, transactional key-value store

36,378

LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.

28,450

A library that provides an embeddable, persistent key-value store for fast storage.

6,211

Seamless multi-master syncing database with an intuitive HTTP/JSON API, designed for reliability

26,228

The MongoDB Database

Quick Overview

Realm Core is the foundational C++ library that powers Realm Database, a fast, efficient, and easy-to-use mobile database solution. It provides the core functionality for data storage, querying, and synchronization, serving as the backbone for Realm's mobile and server-side implementations across various platforms.

Pros

  • High performance and low memory footprint
  • Cross-platform compatibility (iOS, Android, Windows, macOS, Linux)
  • ACID-compliant with support for real-time data synchronization
  • Zero-copy architecture for efficient data access

Cons

  • Steep learning curve for developers new to Realm's concepts
  • Limited flexibility in schema changes compared to some traditional databases
  • Potential complexity in integrating with existing codebases
  • Smaller community compared to more established database solutions

Code Examples

  1. Creating a Realm and defining a model:
#include <realm/object-store/shared_realm.hpp>
#include <realm/object-store/object_schema.hpp>

realm::ObjectSchema person_schema{
    "Person",
    {
        {"name", realm::PropertyType::String},
        {"age", realm::PropertyType::Int}
    }
};

auto config = realm::Realm::Config{.schema_version = 0, .schema = {person_schema}};
auto realm = realm::Realm::get_shared_realm(config);
  1. Adding an object to the Realm:
realm->begin_transaction();

auto person = realm->create<Person>("Person", {{"name", "John Doe"}, {"age", 30}});

realm->commit_transaction();
  1. Querying objects from the Realm:
auto results = realm->objects<Person>().filter("age > 25");

for (const auto& person : results) {
    std::cout << "Name: " << person.name << ", Age: " << person.age << std::endl;
}

Getting Started

To get started with Realm Core:

  1. Clone the repository:

    git clone https://github.com/realm/realm-core.git
    
  2. Build the project:

    cd realm-core
    mkdir build && cd build
    cmake ..
    make
    
  3. Include Realm Core in your C++ project:

    #include <realm/object-store/shared_realm.hpp>
    // Add other necessary headers
    
    // Initialize Realm and start using it in your application
    

Competitor Comparisons

6,288

Fast persistent recoverable log and key-value store + cache, in C# and C++.

Pros of FASTER

  • Designed for high-performance key-value operations with support for larger-than-memory data
  • Offers hybrid log and in-memory index for efficient data management
  • Provides both C# and C++ implementations for flexibility

Cons of FASTER

  • Less mature and widely adopted compared to Realm Core
  • Limited documentation and community support
  • Narrower focus on key-value operations, while Realm Core offers a more comprehensive database solution

Code Comparison

FASTER (C#):

using (var session = store.NewSession(new SimpleFunctions<long, long>()))
{
    session.Upsert(1, 1);
    session.Read(1, out long value);
}

Realm Core (C++):

auto realm = Realm::get_shared_realm(config);
auto table = realm->read_group().get_table("MyTable");
realm->begin_transaction();
table->create_object().set("myColumn", 1);
realm->commit_transaction();

Summary

FASTER focuses on high-performance key-value operations, while Realm Core provides a more comprehensive database solution. FASTER offers potential performance benefits for specific use cases, but Realm Core has broader functionality and stronger community support. The choice between the two depends on the specific requirements of your project and the level of support and maturity you need.

FoundationDB - the open source, distributed, transactional key-value store

Pros of FoundationDB

  • Highly scalable distributed database system
  • Strong consistency and ACID transactions across multiple machines
  • Supports multiple data models through layered architecture

Cons of FoundationDB

  • Steeper learning curve due to its distributed nature
  • Less suitable for mobile or embedded applications
  • Requires more resources to set up and maintain

Code Comparison

FoundationDB (C++):

Transaction tr(db);
tr.set(KeyRef("hello"), ValueRef("world"));
tr.commit().wait();

Realm Core (C++):

auto realm = Realm::get_shared_realm(config);
realm->begin_transaction();
auto dog = realm->create<Dog>("Rex");
realm->commit_transaction();

Key Differences

  • FoundationDB is designed for distributed systems, while Realm Core focuses on local/mobile databases
  • FoundationDB offers strong consistency across distributed setups, whereas Realm Core excels in offline-first scenarios
  • Realm Core provides a more object-oriented API, while FoundationDB uses a key-value approach with optional layers

Both databases have their strengths, with FoundationDB being more suitable for large-scale distributed applications and Realm Core being ideal for mobile and embedded use cases.

36,378

LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.

Pros of LevelDB

  • Simpler key-value store design, making it easier to use for basic storage needs
  • Better performance for write-heavy workloads
  • More mature and widely adopted in various projects

Cons of LevelDB

  • Limited query capabilities compared to Realm Core's object-oriented model
  • Lacks built-in support for multiple data types and complex data structures
  • No native cross-platform mobile support

Code Comparison

LevelDB (C++):

leveldb::DB* db;
leveldb::Options options;
options.create_if_missing = true;
leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);
db->Put(leveldb::WriteOptions(), "key", "value");

Realm Core (C++):

auto realm = Realm::get_shared_realm(config);
realm->begin_transaction();
auto dog = realm->create<Dog>("Rex", 5);
realm->commit_transaction();

LevelDB focuses on simple key-value operations, while Realm Core provides an object-oriented database model with support for complex data structures and relationships. Realm Core offers better cross-platform support and more advanced querying capabilities, making it suitable for mobile app development. However, LevelDB's simplicity and performance make it a good choice for projects requiring basic key-value storage with high write throughput.

28,450

A library that provides an embeddable, persistent key-value store for fast storage.

Pros of RocksDB

  • Highly optimized for fast storage devices like SSDs
  • Offers advanced features like column families and transactions
  • Widely adopted and battle-tested in large-scale production environments

Cons of RocksDB

  • Steeper learning curve and more complex API compared to Realm Core
  • Higher memory usage, especially for large datasets
  • May require more fine-tuning for optimal performance

Code Comparison

RocksDB example:

#include <rocksdb/db.h>

rocksdb::DB* db;
rocksdb::Options options;
options.create_if_missing = true;
rocksdb::Status status = rocksdb::DB::Open(options, "/path/to/db", &db);

Realm Core example:

#include <realm/db.hpp>

auto db = realm::DB::create(realm::DBOptions(realm::Realm::Config::in_memory()));
auto group = db->start_read();
auto table = group->get_table("MyTable");

Both libraries provide C++ APIs for database operations, but RocksDB's interface is more low-level and requires explicit management of database options and status checking. Realm Core offers a higher-level abstraction with a more intuitive API for common database operations.

6,211

Seamless multi-master syncing database with an intuitive HTTP/JSON API, designed for reliability

Pros of CouchDB

  • Mature and battle-tested database with a large community and extensive documentation
  • Built-in support for multi-master replication and conflict resolution
  • RESTful HTTP API for easy integration with web applications

Cons of CouchDB

  • Slower performance for certain types of queries compared to Realm Core
  • Larger resource footprint and more complex setup process
  • Less suitable for mobile and embedded applications

Code Comparison

CouchDB (JavaScript):

const nano = require('nano')('http://localhost:5984');
const db = nano.use('mydb');

db.insert({ name: 'John Doe' }, 'john', (err, body) => {
  if (!err) console.log('Document inserted');
});

Realm Core (C++):

#include <realm.hpp>

realm::DB db = realm::DB::create("mydb");
realm::Table& table = db.add_table("person");
size_t name_col = table.add_column(realm::type_String, "name");
table.create_object().set(name_col, "John Doe");

Both databases offer different approaches to data storage and retrieval. CouchDB uses a document-oriented model with JSON, while Realm Core provides a more traditional object-oriented database structure. The choice between them depends on specific project requirements, such as scalability needs, performance expectations, and target platforms.

26,228

The MongoDB Database

Pros of mongo

  • More mature and widely adopted database system
  • Extensive documentation and large community support
  • Flexible schema design for complex data structures

Cons of mongo

  • Higher resource consumption and slower performance for certain operations
  • Steeper learning curve for advanced features and optimization
  • Less suitable for mobile and edge computing scenarios

Code Comparison

mongo:

const client = new MongoClient(uri);
await client.connect();
const collection = client.db("mydb").collection("users");
await collection.insertOne({ name: "John", age: 30 });
const result = await collection.find({ age: { $gt: 25 } }).toArray();

realm-core:

auto realm = Realm::open(config);
auto users = realm->read_group().get_table("users");
users->create_object().set_all("John", 30);
auto query = users->where().greater("age", 25);
auto results = query.find_all();

Summary

While mongo offers a robust, flexible solution for server-side databases with extensive community support, realm-core provides a lightweight, efficient option better suited for mobile and edge computing. The choice between them depends on specific project requirements, such as scalability needs, performance constraints, and target platforms.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Latest Release Coverage Status Source License

Realm

Realm is a mobile database that runs directly inside phones, tablets or wearables - check out realm.io.

This repository holds the source code for the core database component used by all the Realm Mobile Database products:

Realm Core is not in itself an "end-user" product with a publicly stable and supported API.

Refer to the Atlas Device SDK documentation for information about Realm and using the SDKs.

Building Realm

How to build Realm Core is described here.

Contributing

See CONTRIBUTING.md for more details!

Code of Conduct

This project adheres to the MongoDB Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to community-conduct@mongodb.com.

License

Realm Core is published under the Apache 2.0 license.

See the THIRD-PARTY-NOTICES file for licenses related to included third party libraries.

Feedback

Feedback to the Realm SDK's should be given in the respective SDK's github mentioned in the top of this readme. For anything specifically about Realm Core, please create an issue here.

NPM DownloadsLast 30 Days