Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #18 from florent37/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
florent37 committed Apr 13, 2016
2 parents ff3029d + a8ee8f5 commit 02bae89
Show file tree
Hide file tree
Showing 6 changed files with 1,056 additions and 995 deletions.
57 changes: 33 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,24 @@ buildscript {
apply plugin: 'com.neenbedankt.android-apt'

dependencies {
compile 'fr.xebia.android.freezer:freezer:1.0.6'
provided 'fr.xebia.android.freezer:freezer-annotations:1.0.6'
apt 'fr.xebia.android.freezer:freezer-compiler:1.0.6'
compile 'fr.xebia.android.freezer:freezer:2.0.1'
provided 'fr.xebia.android.freezer:freezer-annotations:2.0.1'
apt 'fr.xebia.android.freezer:freezer-compiler:2.0.1'
}
```

#It's always better with a context

Don't forget to initialise Freezer in your application:

```java
public class MyApplication extends Application {

@Override public void onCreate() {
super.onCreate();
Freezer.onCreate(this);
}

}
```

Expand Down Expand Up @@ -127,6 +142,16 @@ float ageMax = userEntityManager.select().max(UserColumns.age);
int count = userEntityManager.select().count();
```

## Limit

The `QueryBuilder` offers a limitation method, for example, getting 10 users, starting from the 5th:

```java
ist<User> someUsers = userEntityManager.select()
.limit(5, 10) //start, count
.asList();
```

#Asynchronous

Freezer offers various asynchronous methods:
Expand Down Expand Up @@ -246,21 +271,6 @@ You can log all SQL queries from entities managers:
userEntityManager.logQueries((query, datas) -> Log.d(TAG, query) }
```

#It's always better with a context
Don't forget to initialise Freezer in your application:

```java
public class MyApplication extends Application {

@Override public void onCreate() {
super.onCreate();
Freezer.onCreate(this);
}

}
```

#Migration

To handle schema migration, just add `@Migration(newVersion)` in a static method,
Expand Down Expand Up @@ -296,11 +306,6 @@ Migration isn't yet capable of:
- adding/modifying One To One
- adding/modifying One To Many
- handling collections/arrays
#TODO
- Improve migration
- Add Observable support
#Changelog
Expand Down Expand Up @@ -329,12 +334,16 @@ Introduced Migration Engine.
- Model update
##1.0.6
##2.0.0
- Async API
- Support Observables
- Added @DatabaseName
##2.0.1
- Limit
#A project initiated by Xebia
This project was first developed by Xebia and has been open-sourced since. We will continue working on it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,4 +509,35 @@ public void onError(List<User> data) {
assertThat(numberOfUsers.get()).isEqualTo(3);
}

@Test
public void testSelectUsers_limit() {
//given
List<User> users = Arrays.asList(
new User(21, "a", null, null, true),
new User(21, "b", null, null, true),
new User(21, "c", null, null, true),
new User(21, "d", null, null, true),
new User(21, "e", null, null, true),//4
new User(21, "f", null, null, true),
new User(21, "g", null, null, true),
new User(21, "h", null, null, true),
new User(21, "i", null, null, true),
new User(21, "j", null, null, true),
new User(21, "k", null, null, true),
new User(21, "l", null, null, true),
new User(21, "m", null, null, true)
);
userEntityManager.add(users);

//when
List<User> usersFromBase = userEntityManager
.select()
.limit(4,5)
.asList();

//then
assertThat(usersFromBase.size()).isEqualTo(5);
assertThat(usersFromBase.get(0).getName()).isEqualTo("e");
}

}
10 changes: 3 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
Expand All @@ -23,7 +23,7 @@ ext{
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
targetCompatibilityVersion = JavaVersion.VERSION_1_7

libraryVersion="1.0.6"
libraryVersion="2.0.1"
}

allprojects {
Expand All @@ -34,8 +34,4 @@ allprojects {
url "http://dl.bintray.com/florent37/maven"
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
}
Loading

0 comments on commit 02bae89

Please sign in to comment.