From the code below, I would expect the console value to increase every time I run the save()
function. However, the number does not update. So I'm not seeing any created values injected into the store on create.
Budget = DS.defineResource('budget')
function save(){
Budget.create(this.budgetItem, {upsert: true})
.then( ( ) => {
Budget.findAll().then((data)=>console.log(data.length))
})
}
I'm using jsdata-angular.
After the first save findAll()
executes it will retreive records from the server and then cache them. After that it does not make future calls to the server when performing a findAll() (this is expected behavior) however it is also not injecting the newly created values into store either.
All my configs are left unchanged. I'm using all defaults.
DS#findAll
is for retrieving records from a persistence layer via an adapter and loading them into the store. By default, if you make afindAll
call and then make the exact samefindAll
call again (with the samequery
argument), then instead of making a new request, JSData returns to you the original result. You can change this behavior two ways:useFilter
totrue
to have yourfindAll
invocation callDS#filter
and returning you the result.bypassCache
totrue
to force the data to be reloaded via the adapter.As a general rule of thumb,
findAll
is for asynchronously loading records into the store (e.g. via HTTP adapter GET request), andfilter
is for synchronously selecting records out of the store when you need them (e.g. display them in your View).For example, in one place you do:
Then elsewhere: