Skip to content

Commit

Permalink
Add delete data part.
Browse files Browse the repository at this point in the history
  • Loading branch information
sinyu890807 committed Aug 25, 2014
1 parent 9dfecd2 commit 3a6211a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,25 @@ song2.save();
```

#### 3. Update data
Each model which inherits from **DataSupport** would also have **update()** and **updateAll()** method. You can update a single record by a specified id:
Each model which inherits from **DataSupport** would also have **update()** and **updateAll()** method. You can update a single record with a specified id:
``` java
Album albumToUpdate = new Album();
albumToUpdate.setPrice(20.99f); // raise the price
albumToUpdate.update(id);
```
Or you can update multiple records by a where condition:
Or you can update multiple records with a where condition:
``` java
Album albumToUpdate = new Album();
albumToUpdate.setPrice(20.99f); // raise the price
albumToUpdate.updateAll("name = ?", "album");
```

#### 3. Delete data
You can delete a single record using the static **delete()** method in **DataSupport**:
``` java
DataSupport.delete(Song.class, id);
```
Or delete multiple records using the static **deleteAll()** method in **DataSupport**:
``` java
DataSupport.deleteAll(Song.class, "duration > ?" , "350");
```

0 comments on commit 3a6211a

Please sign in to comment.