Git Product home page Git Product logo

active-orm's Introduction

alt text

Build Status

ActiveORM, it is a object relational mapping which follows the active record pattern.

It supports the major databases(SQLite, PostgreSQL, MySQL and H2). It also provides a query module so you can easily query for objects in an object orientated manner.

Use

This will be a quick tutorial on how to use ActiveORM, if you run in to any issues while using ActiveORM feel free to create an issue on this Github page.

Configuration

This framework was built to be as simple as possible so the configuration has been kept to a very minimum.
You will need to create a configuration file for the database you are using(H2Database, SQLite, PostgreSQL, MySQL).
The configuration file needs to be in a yaml format.

connector: postgre
name: testing
username: development
password: supersecretpasswordthatnooneknows

To load the configuration and initialize the Database object simply call

Database.fromYaml("your configuration file here.yml");

ActiveRecord or Model

These classes are used to create a object which is related to a table in your database.
This is a small example of a ActiveRecord implementation.

@Table(name = "users")
public class User extends ActiveRecord {

    @PrimaryKey
    @Column(name = "id")
    public int id;

    @Column(name = "username")
    public String name;

    @Column(name = "password")
    public String password;

}

Query

The Query object allows you to create a query to get ActiveRecords and Models from the database easily but also delete them from the database.
This is a small example of how to use the Query object.

// Queries the database for the first record that matches
// the conditions and then converts it to a User object
final User user Query.build(User.class).where("username").equalTo("Tom").first();
System.out.printLn(user.name);

active-orm's People

Contributors

francismb avatar mattwzawislak avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ibilux

active-orm's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.