Skip to content

add datetime queries in docs #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions objectbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ class Person {

String firstName;
String lastName;
DateTime birthDate;

Person({this.id = 0, required this.firstName, required this.lastName});
Person({this.id = 0, required this.firstName, required this.lastName, required this.birthDate});
}

final store = await openStore();
final box = store.box<Person>();

var person = Person(firstName: 'Joe', lastName: 'Green');
var person = Person(firstName: 'Joe', lastName: 'Green', birthDate: DateTime.utc(1989, 11, 9));

final id = box.put(person); // Create

Expand All @@ -45,6 +46,12 @@ box.remove(person.id); // Delete
// find all people whose name start with letter 'J'
final query = box.query(Person_.firstName.startsWith('J')).build();
final people = query.find(); // find() returns List<Person>

// find all people whose has born between 1988 and 1990
final dateQuery = box.query(
Person_.birthDate.between(DateTime.utc(1988, 1, 1), DateTime.utc(1990, 1, 1))
).build();
final result = query.find(); // find() returns List<Person>
```

Head over to [docs](https://docs.objectbox.io/getting-started) and [examples](example/README.md) for more.
Expand Down