-
Notifications
You must be signed in to change notification settings - Fork 581
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #505 from hellerve/master
Added syntax highlighting in readme
- Loading branch information
Showing
1 changed file
with
10 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ git clone [email protected]:satyan/sugar.git | |
``` | ||
|
||
include this in your **settings.gradle** | ||
``` | ||
```gradle | ||
include ':app' // your module app | ||
include ':sugar' | ||
|
@@ -76,7 +76,7 @@ sugar.dir=/path/to/sugar/library | |
``` | ||
|
||
add sugar project to the dependencies of your main project (build.gradle) | ||
``` | ||
```gradle | ||
dependencies { | ||
compile project(':sugar') | ||
} | ||
|
@@ -88,7 +88,7 @@ After installing, check out how to set up your first database and models [here]( | |
|
||
## Examples | ||
### SugarRecord | ||
``` | ||
```java | ||
public class Book extends SugarRecord { | ||
@Unique | ||
String isbn; | ||
|
@@ -108,38 +108,38 @@ public class Book extends SugarRecord { | |
} | ||
``` | ||
or | ||
``` | ||
```java | ||
@Table | ||
public class Book { ... } | ||
``` | ||
|
||
### Save Entity | ||
``` | ||
```java | ||
Book book = new Book("isbn123", "Title here", "2nd edition") | ||
book.save(); | ||
``` | ||
|
||
### Load Entity | ||
``` | ||
```java | ||
Book book = Book.findById(Book.class, 1); | ||
``` | ||
|
||
### Update Entity | ||
``` | ||
```java | ||
Book book = Book.findById(Book.class, 1); | ||
book.title = "updated title here"; // modify the values | ||
book.edition = "3rd edition"; | ||
book.save(); // updates the previous entry with new values. | ||
``` | ||
|
||
### Delete Entity | ||
``` | ||
```java | ||
Book book = Book.findById(Book.class, 1); | ||
book.delete(); | ||
``` | ||
|
||
### Update Entity based on Unique values | ||
``` | ||
```java | ||
Book book = new Book("isbn123", "Title here", "2nd edition") | ||
book.save(); | ||
|
||
|
@@ -151,7 +151,7 @@ book.getId() == sameBook.getId(); // true | |
``` | ||
|
||
### Bulk Insert | ||
``` | ||
```java | ||
List<Book> books = new ArrayList<>(); | ||
books.add(new Book("isbn123", "Title here", "2nd edition")) | ||
books.add(new Book("isbn456", "Title here 2", "3nd edition")) | ||
|