dboo

0.13.0 • Public • Published

DBOO

DBOO is a NoSQL database, designed particularly for object oriented programming languages. It links directly to C++, C#, Node JS and you store and retrieve objects directly through it’s API. Complete object graphs can be stored in atomic commits, and linked back together upon retrieval of the objects.

DBOO supports a simple C++ inspired query language (in the C++ API the query is c++) and you can create Indices on classes' member fields.

DBOO is a client-server application. The dboo node module is the client side. You will also need the server which can be downloaded from https://dboo.dev.

Features

  • A database for object oriented languages,
  • You store objects in the language you use (C++, C#, Javascript etc), and fetch objects in that language,
  • Can handle inheritance (including multiple inheritence in C++),
  • Stores object graphs, including circular graphs, tree structures etc,
  • Raw pointers, unique_ptr, shared_ptr, dboo::ref (lazy-fetch pointers),
  • Any size objects (from classes with no member fields to GB sized objects),
  • All standard library container types can be used in your classes,
  • Transactional, atomic commits of any number of objects,
  • Keeps all transactions, can go back to previous commit,
  • Available for C++, C#, Node.JS.

License

The dboo node module is licensed under CC BY-NC-ND (Creative Commons, Attribution-NonCommercial-NoDerivs). Contact the developer for other licensing arrangement.

Install

npm install dboo

The module is binary only. If your platform doesn't have a prebuilt binary package, please contact us and we will try to include your platform.

Use

You must describe your classes for dboo. A limitation right now is that the constructor must not take any arguments. DBOO calls the constructor when objects are instantiated as it pulls them from the database.

const dboo = require('dboo');

// A normal class declaration:
class Address {
  streetName;
  streetNumber;
  postCode;
  town;
  
  constructor() {
    // Constructor can do any normal initiation, however as DBOO requires a 
    // constructor without parameters, and javascript can only have one constructor,
    // you end up having to use factory functions if you want to provide arguments
    // (see below)
  }
}

// Describe the class for dboo
// DBOO has a set of types that are used for describing the members. As dboo
// is cross platform and the same objects can be pulled out in C++ or C#, there are
// more number types to choose from than exist in javascript. This class only have
// strings.   
dboo.class(Address,
  [{"streetName": dboo.string},
   {"streetNumber": dboo.string},
   {"postCode": dboo.string},
   {"town": dboo.string}]
);

// Use a factory function to create an object with parameters
newAddress = function(streetName, streetNumber, postCode, town) {
  address = new Address();
  address.streetName = streetName;
  address.streetNumber = streetNumber;
  address.postCode = postCode;
  address.town = town;
  return address;
}

// Another class.
class Person {
  name;

  // address1 and address2 refers to other objects:
  address1 = new Address();
  address2 = new Address();

  constructor() {
  }
}

dboo.class(Person,
  [{"name": dboo.string},
   {"address1": Address}, // When referring to other objects, use the class identifier directly
   {"address2": Address}]
);

Actually using it for committing and retrieving objects:

const dboo = require('dboo');

// Construct an ODB connection object
var odb = new dboo.ODB();
// Connect. You could connect directly with new dboo.ODB('localhost', ... ) as well.
odb.connect('localhost', 2263, 'mydb', 'myuser', 'mypassword');

// Create some objects...
let myperson1 = new Person();
myperson1.name = "Tom";
let myperson2 = new Person();
myperson2.name = "Karl";

// They can refer to the same object for example 
myperson2.address1 = myperson1.address1;

// Commit the objects...
odb.commit([myperson1, myperson2]);


...

// Define a results array:
let results1 = [];
odb.query(results1, 'select<Person>(eq(name, "Tom"))');

// results will now contain the Person named 'Tom'. The two
// Address objects will also be pulled from the database and
// accessible from Person.address1 and address2.

// If we now do
let results2 = [];
odb.query(results2, 'select<Person>(eq(name, "Karl"))');
// results2 will now contain the 'Karl' object. address1 of the
// two Persons will point to the same instance of Address.

Package Sidebar

Install

npm i dboo

Homepage

www.dboo.dev

Weekly Downloads

15

Version

0.13.0

License

CC-BY-NC-ND-4.0

Unpacked Size

5.58 kB

Total Files

3

Last publish

Collaborators

  • dboo