Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example code doesn't have Update operation like com.orm.SugarRecord.save; #185

Closed
LOG-TAG opened this issue Nov 6, 2014 · 2 comments
Closed

Comments

@LOG-TAG
Copy link

LOG-TAG commented Nov 6, 2014

I'm just looking for how to implement update operation like this (Updating Entity) in new 1.4 version comparing to old version.

//old version
Book book = Book.findById(Book.class, 1);
book.title = "updated title here"; // modify the values
book.edition = "3rd edition";
book.save(); 

findById(type, id)// is there  but how to get the id of the retrieved data??

//newversion

 save(new Note(10 + (int) (10 * Math.random()), titleBox.getText().toString(), descBox.getText().toString(), tag));

like in AddNoteActivity of the example!!

@LOG-TAG LOG-TAG changed the title Example code doesn't have Update operation com.orm.SugarRecord.save; Example code doesn't have Update operation like com.orm.SugarRecord.save; Nov 6, 2014
@jivimberg
Copy link
Contributor

+1

@jivimberg
Copy link
Contributor

The way I found to do this is by using the unique attribute. Then you can recover the entity you want to update and during save it will overwrite the previous value.

whoshuu added a commit that referenced this issue Apr 7, 2015
Closes #254
References #185
References #215
References #243

Thanks @jivimberg for the pull request!
@whoshuu whoshuu closed this as completed in 6736197 Apr 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants