ActiveRecord.js 介绍
ActiveRecord.js 是一个开源的JavaScript 对象映射框架,包括:
- Google Gears (client-side persistence)
- In Memory (if no SQL server is available on the client)
- Adobe AIR (client-side persistence)
- SQLite and MySQL (via Aptana Jaxer, the open source Ajax server)
- additional environments (like HTML5) expected to come through working with the community on the project
ActiveRecord.js abstracts away underlying SQL commands so that JavaScript
developers can have a unified API for storing, finding, selecting and
retrieving objects and their data using the ActiveRecord pattern popularized
by the Ruby on Rails community.
示例代码:
- var User = ActiveRecord.define(‘users’,{
- username: ‘’,
- email: ‘’
- });
- User.hasMany(‘articles’);
-
- var ryan = User.create({
- username: ‘ryan’,
- email: 'rjohnson@aptana.com‘
- });
-
- var Article = ActiveRecord.define(‘articles’,{
- name: ‘’,
- body: ‘’,
- user_id: 0
- });
- Article.belongsTo(‘user’);
-
- var a = Article.create({
- name: ‘Announcing ActiveRecord.js’,
- user_id: ryan.id
- });
- a.set(‘name’,’Announcing ActiveRecord.js!!!’);
- a.save();
-
- a.getUser() == ryan;
- ryan.getArticleList()[0] == a;
ActiveRecord.js 官网
http://www.aptana.com/blog/rjohnson/activerecord_js_released_as_beta
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。