Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I reset a collection in Titanium Alloy?
    primarykey
    data
    text
    <p>A Backbonejs collection has a function to <a href="http://docs.appcelerator.com/backbone/0.9.2/#Collection-reset" rel="nofollow">reset a collection</a> for bulk updates. I would like to use this feature in Titanium Alloy when I sync with JSON data from a server but it appears as if this is not being committed/saved to SQLite - I am using an sql adapter.</p> <pre><code>config: { columns: { // stuff name: "TEXT" }, adapter: { type: "sql", collection_name: "pony", db_name: Alloy.CFG.db_name } } </code></pre> <p>I have some jasmine tests which keep failing. FYI I have migration script for development that adds 7 items to the collection so that I have something to work with.</p> <pre><code>describe("pony model", function () { var Alloy = require("alloy") data = {name: "My little pony"}, collection, item; beforeEach(function(){ collection = Alloy.createCollection('pony'); item = Alloy.createModel('pony'); }); // PASSES it('can reset all data', function () { collection.fetch(); expect(collection.length).toEqual(7); collection.reset(data) expect(collection.length).toEqual(1); }) // FAILS it('saves reset data', function () { collection.fetch(); expect(collection.length).toEqual(7); collection.reset(data) collection.fetch() expect(collection.length).toEqual(1); }) afterEach(function () { item.destroy(); }); }) </code></pre> <p>The way this bug shows in the UI is that when I save that when I sync data with the server the TableView shows the new records then when I go to another view and come back to the same TableView the synced data is gone and replaced with the default data.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload