JayData 1.5.1 CTP

Rating: No reviews yet
Downloads: 724
Released: Mar 5, 2016
Updated: Mar 5, 2016 by JayDataOrg
Dev status: Beta Help Icon

Recommended Download

Application JayData 1.5.1 CTP
application, 1205K, uploaded Mar 5, 2016 - 724 downloads

Release Notes

There is no question: our goal is to build the the best OData v4 JavaScript tool, ever. There are a lot things to improve, but we release a Community Technology Preview to show our latest results. You can read more on 1.5.0 CTP features here.

How to try the new OData v4 features

We published an OData v4 service endpoint backed by WebAPI OData, horray.

Thanks to JaySvcUtil, you can pre-generate your data model in node.js command prompt.

npm install -g jaysvcutil
jaysvcutil -m http://odatav4-demo.jaystack.com:9000/odata/$metadata -o context.js

Arrow function support

JayData has improved predicates in Queryables. You can use arrow functions for example in filter conditions.
Old style
ctx.Articles.filter(function (it) { return it.Id > 5 })


New style - using arrow function
ctx.Articles.filter(it => it.Id > 5)


If arrow function isn't supported by your targeted browsers (older IE) then you can use it in string
ctx.Articles.filter('it => it.Id > 5')

Advanced retrieval of related entities through $expand

You can use additional queryable methods on collections to filter/project navigation properties with arrays
Filtering array-valued navigation properties
ctx.Categories.include('c => c.Articles.filter(a => a.Id > 5)')


Projecting array-valued navigation properties
ctx.Categories.include('c => c.Articles.map(a => a.Title)')


Projecting and filtering array-valued navigation properties
ctx.Categories.include('c => c.Articles.filter(a => a.Id > 5).map(a => a.Title)')

Expanding navigation properties of navigation properties

Basic retrieval:
ctx.Categories
  .include('c => c.Articles.Tags')


Retrieval of multiple navigation properties at the same level
ctx.Categories
	.include('c => c.Articles.Tags')
	.include('c => c.Articles.Reviewer')


Expanding pre-filtered navigation properties - result: you will get a list of categories that has a prefiltered article list that match the filter criteria; all article record will be loaded with Tags and Reviewer properties and its values
ctx.Categories
    .include('c => c.Articles.filter(a => a.Id > 5)')
    .include('c => c.Articles.Tags')
    .include('c => c.Articles.Reviewer')
 


Available nested queryable methods:
  • filter
  • map
  • orderBy
  • orderByDescending
  • take
  • skip

Deep insert

You can enable deep insert behavior through the following global configuration property in JayData
$data.defaults.OData.enableDeepSave

If true (default: false) then the provider will discover the deeply insertable entities to reduce the created request numbers
var category = new ctx.Categories.elementType({ Title: 'Javascript' })
var deepInsertArticle = new ctx.Articles.elementType({ Title: 'Deep insert', Lead: 'Lead', Body: 'body', Category: category })
ctx.Articles.add(deepInsertArticle)
ctx.saveChanges()  
 


The result will be only one POST request.
Technical depth: computed fields (such as auto-incremented IDs) of deep-inserted entities aren't returned by current version of ASP.NET WebAPI OData

Function parameter resolution (not enabled by default yet)

There is an other usage of parameters in Queryable predicates
Old style
ctx.Articles.filter(function(it){ return it.Title == this.p1 && it.Lead == this.p2 }, {p1: 'Title', p2: 'Lead'})

New style
ctx.Articles.filter(function(it, p1, p2){ return it.Title == p1 && it.Lead == p2 }, {p1: 'Title', p2: 'Lead'})


You can use function parameters in arrow functions, so it is equivalent with:
ctx.Articles.filter((it, p1, p2) => it.Title == p1 && it.Lead == p2 }, {p1: 'Title', p2: 'Lead'})


To enable this feature with the following global setting (default: true) :
$data.defaults.parameterResolutionCompatibility = false; 

Managing entity relationships

Creating a relationship between entities in .NET

How to set entity references in JayData
There is a global configuration property
$data.defaults.OData.withReferenceMethods


If true (true by default) then OData provider provider will create an additional POST request what handled by this CreateRef action to set navigation property while calling saveChanges() method
var product = products[0];
ctx.Products.attach(product);
product.Supplier = suppliers[0];
ctx.saveChanges();

Removing a relationship between entities

How to remove relationships between entities in JayData
There is a configuration property
$data.defaults.OData.withReferenceMethods 

If true (default: true) then the provider will create an additional DELETE request what handled by this DeleteRef action to clear navigation property while calling saveChanges() method
var product = products[0];
ctx.Products.attach(product);
product.Supplier = null;
ctx.saveChanges();

Reviews for this release

No reviews yet for this release.