About JayData Project

JayData is a unified data access library for JavaScript to CRUD data from different sources like WebSQL, IndexedDB, MongoDb, WebAPI,  OData, HTML5 localStorage, Facebook or YQL. The library can be integrated with KendoUI, Knockout.js, Handlebars.js or Sencha Touch 2 and can be used on Node.js as well.

Please visit our website at http://jaydata.org , or read the release notes for the most current information about this project.

New: use JayData as a server

Use your JayData skills to create data centric business apps that run on the server. Read the blogpost about How to install your own oData server with nodejs and mongoDB. You can even try it now online and get your free app at JayStack.com.

Understand JayData in 7 simple steps. (read this article)

Step 1 - Scripts to reference

<!-- optional, only if you need OData -->
<script  type="text/javascript" src="http://include.jaydata.org/datajs-1.0.3.min.js"></script>
<script  type="text/javascript" src="http://include.jaydata.org/jaydata.min.js"></script>

Step 2 - Define data model

Simple model that works online and offline as well. Define your data model:

$data.Entity.extend("Todo", {
    Id: { type: "int", key: true, computed: true },
    Task: { type: String, required: true, maxLength: 200 },
    DueDate: { type: Date },
    Completed: { type: Boolean }
});

$data.EntityContext.extend("TodoDatabase", {
    Todos: { type: $data.EntitySet, elementType: Todo }
});

Step 3 - Initialize the data storage

OData

var todoDB = new TodoDatabase("http://mysite.com/my.svc");

local

var todoDB = new TodoDatabase("MyTodoDatase");

webSQL

var todoDB = new TodoDatabase({ 
    provider: 'webSql', databaseName: 'MyTodoDatabase' 
});

Step 4 - Create data

//Create
var tasks = todoDB.Todos.addMany([
    { Task: 'Step0: Get this this list', Completed: true },
    { Task: 'Step1: Define your data model'},
    { Task: 'Step2: Initialize data storage'}
]);
todoDB.saveChanges(function() {
    tasks.forEach( function(todo) { alert(task.Id) });
});

Step 5 - Working with data

Filter #1

//Filter #1
todoDB.Todos
        .filter( function(todo) {
            return todo.Completed == true ||
                    todo.Task.startsWith("Step2")
        })
        .forEach( function(todo) {
            yourTemplate.render(todo); 
        });

Filter #2

//Filter #2
todoDB.Todos
        .filter("it.Completed || it.task.startsWith('Step2')")
        .forEach( function(todo) {
            yourTemplate.render(todo); 
        });

Step 6 - Remove

//Simple remove
todoDB.Todos.remove(todo);
todoDB.saveChanges();
//Remove in batch
todoDB.Todos
        .removeAll();

Step 7 - Generate some UI with jQuery

//UI with jQuery
todoDB.Todos
        .include("Person")
        .forEach(function(todo) {
            $('#todos')
                .append('<li>' + todo.Task + ',' + todo.Person.Name + '</li>');
        });

CRUD + Query in Javascript !!

Create or modify data with an approach native to JavaScript: create objects, set properties, assign to collections. Create complex inmemory object graphs and let JayData persist it for you to one of the read/write data sources.

JayData provides JavaScript Language Query (JSLQ) as a tool to query local (in-browser and mobile) and remote data sources witha simple, unified query syntax: JavaScript itself. Much like Microsoft .NET developers can utilize Entity Framework and LINQ on server-side to perform operations on data from different databases.

The aim of JayData library is to give a similar level of abstraction with the help of the $data.Expressions API and the JavaScript language itself.

JayData is cross-platform (runs on HTML5 desktop and mobile browsers, can be hosted in PhoneGap environment on iPhone, iPad and Android) and cross-layer as it works on client-side and server-side (Node.JS).

More information about JayData

Join our community, Like us on Facebook and Follow us on Twitter.

Visit http://jaydata.org for detailed information and documentation.

As JayData covers many technologies and open new fields of development, we encourage you to contribute to the project with new providers or features. Check out the possible ways of contributions here: http://jaydata.org/community/contribute

JavaScript libraries released on CodePlex can be used to develop applications, to get the structured sourcecode to develop JayData itself, visit github.com/jaydata

JayData comes with dual licensing: you can use it under MIT license if ship software software under MIT, but it should be used under GPL if you distribute your software under GPLv2.

Last edited Dec 20, 2012 at 11:21 AM by JayDataOrg, version 73