Skip to content
This repository was archived by the owner on Nov 15, 2021. It is now read-only.

Commit 4460cdf

Browse files
authored
Update README.md
[skip ci]
1 parent 509497c commit 4460cdf

1 file changed

Lines changed: 46 additions & 4 deletions

File tree

README.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,47 @@
66

77
QueryLite is a fluent query API for android sqlite database.
88

9-
**Query** - fluent sqlite query that supports `where`, `orderBy` and `limit` yet. (`distinct`, `having` and `groupBy` will be supported later).
9+
## Classes
10+
11+
### Table, TableSqlite and Table.Wrap
12+
`Table` represents a database table. `Table` used by `Select.from(table)` to create new `Query`. `TableSqlite` - sqlite table (takes android `SQLiteDatabase` as argument),
13+
`Table.Wrap` - default `Table` decorator. `TableSqlite` can be wrapped with `Table.Wrap`:
14+
```java
15+
public final class CarTable extends Table.Wrap {
16+
17+
/**
18+
* Table name.
19+
*/
20+
private static final String NAME = "cars";
21+
22+
public CarTable(final SQLiteDatabase database) {
23+
super(
24+
new TableSqlite(
25+
CarTable.NAME,
26+
database
27+
)
28+
);
29+
}
30+
}
31+
```
32+
33+
### Select
34+
`Select` shoud specify columns to select from `Table`, `Select.from` can be wrapped with `Query.Wrap` decorator:
35+
```java
36+
public final class CarEngineQuery extends Query.Wrap {
37+
38+
public CarEngineQuery(final SQLiteDatabase database) {
39+
super(
40+
new Select("engine")
41+
.from(new CarTable(database))
42+
);
43+
}
44+
}
45+
```
46+
47+
### Query and Query.Wrap
48+
`Query` - fluent sqlite query that supports `where`, `orderBy` and `limit` yet. (`distinct`, `having` and `groupBy` will be supported later).
49+
1050

1151
`where` - produces [sqlite WHERE clause](https://www.sqlite.org/lang_select.html#whereclause).
1252
> If a WHERE clause is specified, the WHERE expression is evaluated for each row in the input data as a boolean expression. Only rows for which the WHERE clause expression evaluates to true are included from the dataset before continuing. Rows are excluded from the result if the WHERE clause evaluates to either false or NULL.
@@ -41,16 +81,18 @@ query
4181
.where("id = ? AND name = ?", 42, "David")
4282
```
4383

84+
4485
### CursorQuery
4586
It's a decorator for android [Cursor](https://developer.android.com/reference/android/database/Cursor.html), that take `Query` as argument:
4687
```java
4788
import android.database.CursorWrapper;
4889

49-
public final class ItemsByName extends CursorWrapper {
50-
public ItemsByName(final Query query) {
90+
public final class OrderedCarEnginesCursor extends CursorWrapper {
91+
public OrderedCarEnginesCursor(final SQLiteDatabase database) {
5192
super(
5293
new CursorQuery(
53-
query.orderBy("name")
94+
new CarEngineQuery(database)
95+
.orderBy("engine")
5496
)
5597
);
5698
}

0 commit comments

Comments
 (0)