Our new release is available on Github and CodePlex. It includes the following:
Working on a project with JayData?
Need some advice? Need to meet some crazy deadlines and you need some help? Contact the JayData team and get some expert support here!
JayData oData provider in action. See how easy to create a simple HTML5 based CRUD application from the Northwind database.
More videosInitialize your resource like stylesheets, scripts and so on.
<script src="http://include.jaydata.org/jaydata.js"</script>
<script src="http://include.jaydata.org/datajs-1.0.3.js"</script> <script src="http://include.jaydata.org/jaydata.js"</script>
<script src="http://code.jquery.com/jquery.min.js"</script> <script src="http://include.jaydata.org/jaydata.js"</script>
<script src="http://include.jaydata.org/knockout-2.1.0.js"</script> <script src="http://include.jaydata.org/jaydata.js"</script> <script src="http://include.jaydata.org/jaydatamodules/knockout.js"</script>
<script src="http://cdn.kendostatic.com/2012.2.710/js/kendo.all.min.js"</script> <script src="http://include.jaydata.org/jaydata.js"</script> <script src="http://include.jaydata.org/jaydatamodules/kendo.js"</script>
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 } });
The local item store provides an automatic client storage facitlity for every entity type.
Just define your model type and the rest is handled by the library:
$data.Entity.extend("Todo", { Id: { type: "int", key: true, computed: true }, Task: { type: String, required: true, maxLength: 200 }, DueDate: { type: Date }, Completed: { type: Boolean } });
Model types an have relationships to enforce referencial integrity
$data.Entity.extend("Todo", { Id: { type: "int", key: true, computed: true }, Task: { type: String, required: true, maxLength: 200 }, DueDate: { type: Date }, Completed: { type: Boolean }, Person: { type: "Person", required: true, inverseProperty: "Todos"} }); $data.Entity.extend("Person", { Id: { type: "int", key: true, computed: true }, Name: { type: String, required: true, maxLength: 200 }, Todos: { type: Array, elementType: Todo, inverseProperty: "Person" } }); $data.EntityContext.extend("TodoDatabase", { Todos: { type: $data.EntitySet, elementType: Todo }, People: { type: $data.EntitySet, elementType: Person } });
Model entities can have complex properties that are entities themselves
$data.Entity.extend("Location", { City: { type: String }, Country: { type: String }, }); $data.Entity.extend("Todo", { Id: { type: "int", key: true, computed: true }, Task: { type: String, required: true, maxLength: 200 }, DueDate: { type: Date }, Completed: { type: Boolean }, Location: { type: Location } }); $data.EntityContext.extend("TodoDatabase", { Todos: { type: $data.EntitySet, elementType: Todo } });
var todoDB = new TodoDatabase("MyTodoDatase"); todoDB.onReady(function() { //Work with todoDB now });
var todoDB = new TodoDatabase({ provider: 'webSql', databaseName: 'MyTodoDatabase' }); todoDB.onReady(function() { //Work with todoDB now });
var todoDB = new TodoDatabase({ provider: 'indexedDb', databaseName: 'MyTodoDatabase' }); todoDB.onReady(function() { //Work with todoDB now });
var todoDB = new TodoDatabase('http://mysite/myapi'); todoDB.onReady(function() { //Work with todoDB now });
var todoDB = new TodoDatabase('jaystorm:http://mysite/myapi'); todoDB.onReady(function() { //Work with todoDB now });
var todoDB = new TodoDatabase({ provider: 'mongoDB' , databaseName: 'MyTodoDatabase' }); todoDB.onReady(function() { //Work with todoDB now });
var todoDB = new TodoDatabase({ provider: 'sqLite' , databaseName: 'MyTodoDatabase' }); todoDB.onReady(function() { //Work with todoDB now });
//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(todo.Id) }); });
//Create with types var todo = new Todo(); todo.Task = "Step4: create entity"; todo.DueDate = new Date(); todoDB.add(todo); todoDB.saveChanges().then(function() { alert("done!"); });
//Create in Local Item Store var todo = new Todo({ Task: 'Step3: advanced'}); todo.save(function() { alert(todo.Id); });
//Create related data todoDB.Todos.add({ Task: "Your task", Person: new Person({Name: 'Peter'}); }); todoDB.saveChanges();
//Update data var todo = todoDB.Todos.attach({ Id:1}); todo.Completed = true; todoDB.saveChanges();
//Filter #1 todoDB.Todos .filter( function(todo) { return todo.Completed == true || todo.Task.startsWith("Step2") }) .forEach( function(todo) { yourTemplate.render(todo); });
//Filter #2 todoDB.Todos .filter("it.Completed || it.Task.startsWith('Step2')") .forEach( function(todo) { yourTemplate.render(todo); });
//Use TypeScript todoDB.Todos .filter(todo => todo.Completed == true) .map(todo => todo.Task ) .forEach(taskName => $('#list') .append('Task: ' + taskName + ' completed'));
//Filter on relations todoDB.Todos .filter("it.Person.Name == 'Peter'") .toArray( function(todos) { });
//Ordering and shaping todoDB.Todos .orderBy("it.DueDate") .map(function(todo) { return todo.Task }) .toArray(function(taskNameArray) { });
//Simple remove
todoDB.Todos.remove(todo);
todoDB.saveChanges();
//Remove in batch
todoDB.Todos
.removeAll();
//Remove with query todoDB.Todos .filter("it.Completed == true") .removeAll(function() { alert("items removed"); });
//UI with jQuery todoDB.Todos .include("Person") .forEach(function(todo) { $('#todos') .append('<li>' + todo.Task + ',' + todo.Person.Name + '</li>'); });
//UI with Knockout function viewModel() { var self = this; self.todos = ko.observableArray(); todoDB.Todos .include("Person") .toArray(self.todos); } ko.applyBindings(new viewModel());
Designed to make full use of Visual Studio JavaScript IntelliSense to provide the best developer experience
JSLQ brings the philosophy of Entity Framework and LINQ from the .NET platform to the world of JavaScript
Experience the true power of JavaScript, run your code on mobile devices, in web browsers or on a NodeJS serverside
Build full-featured applications powered by HTML5, capitalize on your expertise as a web developer!
JayData is a standards-based, cross-platform Javascript library and a set of practices to access and manipulate data from various online and offline sources.
You can use the out-of-box JayData provider to access Windows Azure store, LocalStore, IndexedDb or Facebook data from JavaScript.
The world's first platform as a service for JavaScript Business Apps! JayStack provides a set of products and services that can help you thrive in the cross-platform, cross-device era.
dbcontext
.Products
.filter(function (p) {
return p.Category.ID == 42
}).skip(10).take(5)
.toArray();
var product = new Northwind.Product({
ProductName: 'Lady Gray Tea',
Cateogory : new Northwind.Category('Teas')
});
Northwind.Products.add(product);
Northwind.saveChanges();