Skip to content

Client libraries beta

PyPInpmRubyGemsPackagistCrates.ioGo

ortfo/db exports its type definitions for use in various programming languages. This is mainly useful to access data from the exported database.json file in a type-safe way.

It's like an ORM, but for your JSON database!

Available clients

Python

Installation

Install ortfodb on pypi.org:

bash
pip install ortfodb
bash
poetry add ortfodb

Usage

python
from ortfodb import database_from_dict
import json

with open("path/to/the/database.json") as f:
    database = database_from_dict(json.load(f))

TypeScript (and JavaScript)

Installation

Install @ortfo/db on npmjs.com:

bash
npm install @ortfo/db
bash
yarn add @ortfo/db
bash
pnpm add @ortfo/db
bash
bun add ortfodb

Usage

typescript
import { Database } from "@ortfo/db";

const database = Database.toDatabase(jsonStringOfTheDatabase);

Ruby

Installation

Install ortfodb on rubygems.org:

ruby
gem 'ortfodb', '~> 1.6.1'
ruby
Gem::Specification.new do |spec|
  spec.name = 'my_gem'
  ...
  spec.add_dependency 'ortfodb', '~> 1.6.1'
end

Usage

ruby
require 'ortfodb/database'

database = Ortfodb::Database.from_json! json_string

Rust

Installation

Install ortfodb on crates.io:

bash
cargo add ortfodb
toml
[dependencies]
ortfodb = "1.6.1"

Usage

rust
use ortfodb::Database;

let database: Database = serde_json::from_str(&json_string).unwrap();

PHP

See https://github.com/ortfo/db/tree/main/packages/php

WARNING

It's not on Packagist yet because packagist expects a composer.json file at the root of the repository

Installation

TODO

Usage

WARNING

I haven't programmed in PHP in a while, so this might be wrong. Please open an issue if you find a mistake.

php
<?php

use Ortfo\Db\Database;

$json = json_decode(file_get_contents('path/to/the/database.json'), true);
$database = Database::from($json);

Using Go?

Since ortfo/db is programmed in Go, you can use the ortfo/db's Go package directly, see the Go package documentation. The Database type is probably what you're looking for.

Client libraries versions

The versions of the package are synchronized with the versions of ortfo/db, so you can always know which version of the client library to use.

How it's done

The client libraries are generated from the various JSON schemas of ortfo/db, thanks to quicktype. This way, they are always up-to-date!