Skip to content

Commit

Permalink
Merge pull request #505 from hellerve/master
Browse files Browse the repository at this point in the history
Added syntax highlighting in readme
  • Loading branch information
sibelius committed Jan 21, 2016
2 parents 3de393c + 5924594 commit 1d944a2
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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')
}
Expand All @@ -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;
Expand All @@ -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();

Expand All @@ -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"))
Expand Down

0 comments on commit 1d944a2

Please sign in to comment.