{ "id": "115035", "key": "ALOY-679", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "11113", "key": "ALOY", "name": "Alloy", "projectCategory": { "id": "10400", "description": "Tools for developing applications", "name": "Tooling" } }, "fixVersions": [ { "id": "15889", "description": "2014 Sprint 05", "name": "2014 Sprint 05", "archived": true, "released": true, "releaseDate": "2014-03-14" } ], "resolution": { "id": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2014-03-12T18:12:28.000+0000", "created": "2013-05-28T16:26:48.000+0000", "priority": null, "labels": [ "Alloy" ], "versions": [], "issuelinks": [], "assignee": null, "updated": "2018-03-07T22:26:01.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "13605", "name": "Models" } ], "description": "Hi, I want to know how possible set defaults on Model config definition that use pre sqlite file without set to sqlite file I set to model config like this but it's not working\r\n\r\nthis is my config:\r\n{code} \r\nexports.definition = {\r\n config: {\r\n \"adapter\": {\r\n \"type\": \"sql\",\r\n \"collection_name\": \"product\",\r\n \"db_file\": \"/db.sqlite\",\r\n \"idAttribute\": \"id\",\r\n \"remoteBackup\": false\r\n },\r\n \"defaults\": {\r\n \"image\": \"/images/defaultProduct.png\"\r\n }\r\n },\r\n extendModel: function (Model) {\r\n _.extend(Model.prototype, {\r\n \r\n });\r\n // end extend\r\n \r\n return Model;\r\n },\r\n \r\n extendCollection: function (Collection) {\r\n _.extend(Collection.prototype, {\r\n \r\n });\r\n // end extend\r\n \r\n return Collection;\r\n }\r\n};\r\n{code} \r\n\r\n", "attachment": [], "flagged": false, "summary": "Defaults for pre sqlite file", "creator": { "name": "navid_gh", "key": "navid_gh", "displayName": "Navid Ghahramani", "active": true, "timeZone": "Asia/Tehran" }, "subtasks": [], "reporter": { "name": "navid_gh", "key": "navid_gh", "displayName": "Navid Ghahramani", "active": true, "timeZone": "Asia/Tehran" }, "environment": null, "comment": { "comments": [ { "id": "254931", "author": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Navid,\n\nQuestions or concerns about coding practices or how to do X are not considered bugs and belong in the QA community boards. The Titanium Community Jira is a place to log known bugs or issues with the platform/SDK. Please direct your question to the boards here: https://developer.appcelerator.com/questions/newest\n\nRegards,\nCarter", "updateAuthor": { "name": "clathrop", "key": "clathrop", "displayName": "Carter Lathrop", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-30T19:18:03.000+0000", "updated": "2013-05-30T19:18:03.000+0000" }, { "id": "254939", "author": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~clathrop] the issue originated from a Q&A question and I asked Navid to add his case here.", "updateAuthor": { "name": "tlukasavage", "key": "tlukasavage", "displayName": "Tony Lukasavage", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-30T19:35:01.000+0000", "updated": "2013-05-30T19:35:01.000+0000" }, { "id": "254950", "author": { "name": "navid_gh", "key": "navid_gh", "displayName": "Navid Ghahramani", "active": true, "timeZone": "Asia/Tehran" }, "body": "Please Tony add to this issue for support SQLite file defaults while inserting.\r\nRefer to:\r\n[Defaults on sqlite file|http://developer.appcelerator.com/question/153006/defaults-value-does-not-working]", "updateAuthor": { "name": "navid_gh", "key": "navid_gh", "displayName": "Navid Ghahramani", "active": true, "timeZone": "Asia/Tehran" }, "created": "2013-05-30T20:02:20.000+0000", "updated": "2013-05-30T20:03:27.000+0000" }, { "id": "296826", "author": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "body": "In my tests, extending the model like this works:\n\n{code}\nextendModel : function(Model) {\n _.extend(Model.prototype, {\n validate: function (attrs) {\n for (var key in attrs) {\n var value = attrs[key];\n if (key === \"image\") {\n if (value.length === 0) {\n // no image value set\n attrs[key] = '/images/defaultProduct.png';\n Model.prototype.save.call(this, attrs);\n }\n }\n }\n }\n });\n // end extend\n\n return Model;\n}\n{code}", "updateAuthor": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "created": "2014-03-12T18:11:11.000+0000", "updated": "2014-03-12T18:11:11.000+0000" }, { "id": "296828", "author": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "body": "Closing as won't fix because there's a workable method to accomplish the desired outcome without making Alloy changes.", "updateAuthor": { "name": "skypanther", "key": "skypanther", "displayName": "Tim Poulsen", "active": true, "timeZone": "America/New_York" }, "created": "2014-03-12T18:12:28.000+0000", "updated": "2014-03-12T18:12:28.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }