All Projects → cockroachdb → Examples Orms

cockroachdb / Examples Orms

Licence: apache-2.0
Sample uses of CockroachDB with popular ORMs

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Examples Orms

Sqlite orm
❤️ SQLite ORM light header only library for modern C++
Stars: ✭ 1,121 (+1624.62%)
Mutual labels:  sql, orm
Records
SQL for Humans™
Stars: ✭ 6,761 (+10301.54%)
Mutual labels:  sql, orm
Sequelize
An easy-to-use and promise-based multi SQL dialects ORM tool for Node.js
Stars: ✭ 25,422 (+39010.77%)
Mutual labels:  sql, orm
Exposed
Kotlin SQL Framework
Stars: ✭ 5,753 (+8750.77%)
Mutual labels:  sql, orm
Fluent
Vapor ORM (queries, models, and relations) for NoSQL and SQL databases
Stars: ✭ 1,071 (+1547.69%)
Mutual labels:  sql, orm
Lucid
AdonisJS official SQL ORM. Supports PostgreSQL, MySQL, MSSQL, Redshift, SQLite and many more
Stars: ✭ 613 (+843.08%)
Mutual labels:  sql, orm
Smartsql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
Stars: ✭ 775 (+1092.31%)
Mutual labels:  sql, orm
Pg
Golang ORM with focus on PostgreSQL features and performance
Stars: ✭ 4,918 (+7466.15%)
Mutual labels:  sql, orm
Gorose
GoRose(go orm), a mini database ORM for golang, which inspired by the famous php framwork laravle's eloquent. It will be friendly for php developer and python or ruby developer. Currently provides six major database drivers: mysql,sqlite3,postgres,oracle,mssql, Clickhouse.
Stars: ✭ 947 (+1356.92%)
Mutual labels:  sql, orm
Express Knex Objection
A simple API system on a pg database, using knex and objection to simplify connection and management
Stars: ✭ 20 (-69.23%)
Mutual labels:  sql, orm
Go Sqlbuilder
A flexible and powerful SQL string builder library plus a zero-config ORM.
Stars: ✭ 539 (+729.23%)
Mutual labels:  sql, orm
Objectivesql
ObjectiveSQL is an ORM framework in Java based on ActiveRecord pattern, which encourages rapid development and clean, codes with the least and convention over configuration.
Stars: ✭ 1,109 (+1606.15%)
Mutual labels:  sql, orm
Qb
The database toolkit for go
Stars: ✭ 524 (+706.15%)
Mutual labels:  sql, orm
Godb
A Go SQL query builder and struct mapper.
Stars: ✭ 651 (+901.54%)
Mutual labels:  sql, orm
Sagacity Sqltoy
基于java语言比mybatis更实用的orm框架,支持mysql、oracle、postgresql、sqlserver、db2、dm、mongodb、elasticsearch、tidb、guassdb、kingbase、oceanbase、greenplum
Stars: ✭ 496 (+663.08%)
Mutual labels:  sql, orm
Nano Sql
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
Stars: ✭ 717 (+1003.08%)
Mutual labels:  sql, orm
Jooq
jOOQ is the best way to write SQL in Java
Stars: ✭ 4,695 (+7123.08%)
Mutual labels:  sql, orm
Openrecord
Make ORMs great again!
Stars: ✭ 474 (+629.23%)
Mutual labels:  sql, orm
Ktorm
A lightweight ORM framework for Kotlin with strong-typed SQL DSL and sequence APIs.
Stars: ✭ 843 (+1196.92%)
Mutual labels:  sql, orm
Reform
A better ORM for Go, based on non-empty interfaces and code generation.
Stars: ✭ 1,103 (+1596.92%)
Mutual labels:  sql, orm

Cockroach ORM examples

This repo contains example uses of CockroachDB with popular ORMs. Each example will implement the sample application spec presented below.

See the CockroachDB ORM Compatibility Plan for a roadmap towards supporting various ORMs.

Installation

Clone this repo into your $GOPATH manually, e.g.,

$ cd ~/go/src/github.com/cockroachdb
$ git clone https://github.com/cockroachdb/examples-orms

This is required because this project uses Go to drive the automated tests, so it will look for things in your $GOPATH. If you try to clone it to a non-$GOPATH directory, it will fail roughly as follows:

$ cd ~/some/random/dir/examples-orms
$ make test
go test -v -i ./testing
testing/api_handler.go:13:2: cannot find package "github.com/cockroachdb/examples-orms/go/gorm/model" in any of:
	/usr/local/Cellar/go/1.10/libexec/src/github.com/cockroachdb/examples-orms/go/gorm/model (from $GOROOT)
	/Users/rloveland/go/src/github.com/cockroachdb/examples-orms/go/gorm/model (from $GOPATH)
testing/api_handler.go:11:2: cannot find package "github.com/pkg/errors" in any of:
	/usr/local/Cellar/go/1.10/libexec/src/github.com/pkg/errors (from $GOROOT)
	/Users/rloveland/go/src/github.com/pkg/errors (from $GOPATH)
make: *** [test] Error 1

However, this is not actually a Go project, so go get -d will also fail (hence the need to manually clone).

$ go get -d github.com/cockroachdb/examples-orms
package github.com/cockroachdb/examples-orms: no Go files in /Users/rloveland/go/src/github.com/cockroachdb/examples-orms

Testing

To run automated testing against all ORMs using the latest binary of CockroachDB, run:

$ make test

To run automated testing against all ORMs using a custom CockroachDB binary, run:

$ make test COCKROACH_BINARY=/path/to/binary/cockroach

Project Structure

The repository contains a set of directories named after programming languages. Beneath these language directories are sub-directories named after specific ORM used for example application implementations.

Each ORM example uses whatever build tool is standard for the language, but provides a standardized Makefile with a start rule, which will start an instance of the sample application.

For instance, the directory structure for an example application of the Hibernate ORM will look like:

java
└── hibernate
    ├── Makefile
    └── example_source

Sample App

The sample application which each example implements is a JSON REST API modeling a company with customers, products, and orders. The API exposes access to the management of this company.

The purpose of the example application is to test common data access patterns so that we can stress various features and implementation details of each language/ORM.

Schema

An ideal schema diagram for the sample application looks like:

Customer
  |
  v
Order  <->  Product

The schema is implemented by each application using ORM-specific constructs to look as close as possible to:

CREATE DATABASE IF NOT EXISTS company_{language}_{ORM};

CREATE TABLE IF NOT EXISTS customers (
  id           SERIAL PRIMARY KEY,
  name         STRING
);

CREATE TABLE IF NOT EXISTS orders (
  id           SERIAL PRIMARY KEY,
  subtotal     DECIMAL(18,2)
  customer_id  INT    REFERENCES customers(id),
);

CREATE TABLE IF NOT EXISTS products (
  id           SERIAL PRIMARY KEY,
  name         STRING,
  price        DECIMAL(18,2)
);

CREATE TABLE IF NOT EXISTS product_orders (
  id           SERIAL PRIMARY KEY,
  product_id   INT    REFERENCES products(id),
  order_id     INT    REFERENCES orders(id) ON DELETE CASCADE
);

JSON API

Each example will expose a RESTful JSON API. The endpoints and example curl command lines are:

GET    /customer
    curl http://localhost:6543/customer

GET    /customer/:id
    curl http://localhost:6543/customer/1

POST   /customer
    curl -X POST -d '{"id": 1, "name": "bob"}' http://localhost:6543/customer

PUT    /customer/:id
    curl -X PUT -d '{"id": 2, "name": "robert"}' http://localhost:6543/customer/1

DELETE /customer
    curl -X DELETE http://localhost:6543/customer/1

GET    /product
    curl http://localhost:6543/product

GET    /product/:id
    curl http://localhost:6543/product/1

POST   /product
    curl -X POST -d '{"id": 1, "name": "apple", "price": 0.30}' http://localhost:6543/product

PUT    /product
DELETE /product

GET    /order
    curl http://localhost:6543/order

GET    /order/:id
    curl http://localhost:6543/order/1

POST   /order
    curl -X POST -d '{"id": 1, "subtotal": 18.2, "customer": {"id": 1}}' http://localhost:6543/order

PUT    /order
DELETE /order

The semantics of each endpoint will be fleshed out when necessary.

Unresolved Questions

  • Can the schema be completely standardized across ORMs without too much of a hassle with overriding default type and naming conventions?
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].