Client libraries beta
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:
pip install ortfodb
poetry add ortfodb
Usage
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:
npm install @ortfo/db
yarn add @ortfo/db
pnpm add @ortfo/db
bun add ortfodb
Usage
import { Database } from "@ortfo/db";
const database = Database.toDatabase(jsonStringOfTheDatabase);
Ruby
Installation
Install ortfodb
on rubygems.org:
gem 'ortfodb', '~> 1.6.1'
Gem::Specification.new do |spec|
spec.name = 'my_gem'
...
spec.add_dependency 'ortfodb', '~> 1.6.1'
end
Usage
require 'ortfodb/database'
database = Ortfodb::Database.from_json! json_string
Rust
Installation
Install ortfodb
on crates.io:
cargo add ortfodb
[dependencies]
ortfodb = "1.6.1"
Usage
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
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!