GithubHelp home page GithubHelp logo

arjs's Introduction

Ruby on Rails like ActiveRecord for javascript using html5 localstorage on JS.Class

Every request is asynchronous, so you do not get a result back, but provide a callback that is called when the query is finished. Later Sync should be used, but so far openDatabaseSync is not implemented in any browser.

Just some basic plumbing done(see below), help appreciated!

  • AR.connection().execute('SQL', function(resultAsHash){ ... })
  • u = User.new({name:'xxx'}); u.name == 'xxx'; u.save
  • User.create({name: 'Bla blub', foo: 1111})
  • User.all(function(users){ ... })
  • User.all({conditions: "name = 1", limit: 1, offset: 2, having: .... }, function(users){ ... })
  • User.find(id, function(user){ ... })

Usage

<script src="vendor/js.class/core.js"></script>
<script src="lib/ar.js"></script>
<script>
  AR.connection().execute("DROP TABLE User")
  User = new JS.Class(AR, {extend: {
    tableName:'User',
    columns: [
      ['id', 'REAL UNIQUE'],
      ['name', 'STRING'],
      ['foo', 'INTEGER'],
      ['bar', 'TEXT']
    ]
  }})
  User.createTable()

Using Example:

  • example test.html needs to be accessed as root on e.g. localhost
  • if you have rack: go into folder and rackup, then go to localhost:9292/test.html

TODO

  • first / count / sum
  • joining
  • associations (belongsTo / HasMany)

arjs's People

Contributors

grosser avatar

Stargazers

Daniel Farias avatar Jeferson Kaefer avatar  avatar Xavier Lacot avatar  avatar

Watchers

 avatar James Cloos avatar Jeferson Kaefer avatar  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.