Closed redvex closed 11 years ago
Additional notes:
var chapter = Models.Chapter.findOneById(_cid); Ti.API.info(chapter.title); [INFO] First chapter chapter.title = "title modified 1" Ti.API.info(chapter.title); [INFO] title modified 1 chapter.save(); Ti.API.info(chapter.title); [INFO] First chapter
so… why?
And this is the update query:
[INFO] update chapter set id = 1, project_id = 1, title = 'First chapter', text = NULL, position = 1 where id = "1"
So the problem should be the assignment, not the save process itself
You should use the setters to update the model, not direct assigning.
chapter.fromArray({title: 'title 1' , chapter:'chapter 1'});
chapter.save()
I've a simple model with "title" and "text" attribute
var chapter = Models.Chapter.findOneById(_id);
chapter.title = "title 1"; chapter.text = "text 1";
when i do
chapter.save();
nothing happens to db.
This is the log of my model:
[INFO] { "_data" = { id = 1; position = 1; "project_id" = 1; text = "";
title = "Primo capitolo";
};
"_options" = {
table = {
all = "<KrollCallback: 0xb573120>";
count = "<KrollCallback: 0xb575df0>";
deleteRecords = "<KrollCallback: 0xb55ea10>";
exists = "<KrollCallback: 0xb56c5c0>";
findBy = "<KrollCallback: 0xb563e40>";
findById = "<KrollCallback: 0xb55d610>";
findOneBy = "<KrollCallback: 0xb56cd00>";
findOneById = "<KrollCallback: 0xb56e910>";
getColumns = "<KrollCallback: 0xb563d70>";
newRecord = "<KrollCallback: 0xb568d60>";
options = {
columns = {
id = "INTEGER PRIMARY KEY AUTOINCREMENT";
position = INTEGER;
"project_id" = INTEGER;
text = TEXT;
title = TEXT;
};
objectMethods = {
getThumb = "<KrollCallback: 0xb552d50>";
};
table = chapter;
};
save = "<KrollCallback: 0xb56b070>";
table = chapter;
truncate = "<KrollCallback: 0xb56f1a0>";
};
};
"_originalData" = {
id = 1;
};
destroy = "<KrollCallback: 0xb56bbf0>";
fromArray = "<KrollCallback: 0xb571540>";
get = "<KrollCallback: 0xb5761c0>";
getThumb = "<KrollCallback: 0xb5691f0>";
id = 1;
isChanged = "<KrollCallback: 0xb56a9a0>";
isNew = "<KrollCallback: 0xb56c9f0>";
position = 1;
"project_id" = 1;
save = "<KrollCallback: 0xb5634d0>";
set = "<KrollCallback: 0xb576df0>";
text = "Prova 1 2 3";
title = "Primo capitolo";
toArray = "<KrollCallback: 0xb54b0b0>";
}