Giter Site home page Giter Site logo

sabres's Introduction

Sabres

Sabres is an ORM library that exposes a Parse-like API.

Features

  • Schemaless: No need to define a schema for your objects. Sabres will dynamicly update schema changes.

  • Auto indexing: No need to define indices. Sabres will handle that for you.

  • No Migration: As schemas are dynamic, there are no "database versions".

  • No Sqlite: the API fully abstracts all Sqlite interfaces, while still giving you most of the functionality.

  • Simple and powerfull API: Well... everyone says that about their libraries, but don't take my word for it, just scroll down a bit.

Quick Start

Create your model by extending SabresObject.

public class Movie extends SabresObject {
    private static final String TITLE_KEY = "title";
    private static final String YEAR_KEY = "year";

    public String getTitle() {
        return getString(TITLE_KEY);
    }

    public void setTitle(String title) {
        put(TITLE_KEY, title);
    }

    public Short getYear() {
        return getShort(YEAR_KEY);
    }

    public void setYear(Short year) {
        put(YEAR_KEY, year);
    }

Initialize Sabres and register your model classes.

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        SabresObject.registerSubclass(Movie.class);
        Sabres.initialize(this);
    }

Create a new Movie object and save it to Sabres:

Movie movie = new Movie();
movie.setTitle("Fight Club");
movie.setYear(1999);
movie.saveInBackground(new SaveCallback() {
    @Override
    public void done(SabresException e) {
        if (e == null) {
            // save was successful
        } else {
            // Save failed 
        }
      }
});

Query the Sabres Database with the SabresQuery object:

  SabresQuery<Movie> query = SabresQuery.getQuery(Movie.class);
  query.whereEqualTo(TITLE_KEY, title);
  query.findInBackground(new FindCallback<Movie>() {
          @Override
          public void done(List<Movie> objects, SabresException e) {
          if (e == null) {
              if (objects.isEmpty()) {
                  // did not find any objects matching query
              } else {
                  // found some objects
              }
          } else {
              // query failed.
          }
});

Please see Wiki for full documentation or Javadoc for... well.. for Javadoc.

Installation

 compile ('com.sabres:sabres:0.9.18@aar') {
        transitive = true;
 }

License

Copyright 2015 Tamir Shomer

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

sabres's People

Contributors

tamir7 avatar netanelgilad avatar

Watchers

James Cloos avatar Jiang Lu avatar

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.