I have a data model as follows in jaydata
Model.js
$data.Entity.extend('Expense', {
Id: { type: 'int', key: true, computed: true },
Name: { type: 'string' },
Date: { type: Date },
Price: { type: 'number' }
});
$data.Entity.extend('Regular', {
Id: { type: 'int', key: true, computed: true },
Name: { type: 'string' },
Price: { type: 'number' }
});
$data.EntityContext.extend("ExpenseDatabase", {
Expenses: { type: $data.EntitySet, elementType: Expense },
Regulars: { type: $data.EntitySet, elementType: Regular }
});
I want to filer the results by Date, which i havent been able to. Can someone help me with this regard? My code for filtering is as follows. But its not working, throws up a type error.
var d = new Date();
exDB.Expenses
.filter( function(exp) {
return exp.Date.day() == d.getDate();
})
.forEach( function(exp) {
alert(exp.Name + exp.Date.getDate());
toAdd = '<li><a>'+exp.Name+'<span class="ui-li-count">'+exp.Price+'</span></a></li>';
$("#expenseList").append(toAdd);
$("#expenseList").listview("refresh");
});
The generic solution would be to write a query with two conditions that checks for an interval: