Skip to content

Commit 80cca76

Browse files
authored
Merge pull request #60 from objectbox/dev
v0.4.0 release
2 parents db87258 + 76ee673 commit 80cca76

File tree

174 files changed

+4420
-607
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+4420
-607
lines changed

.github/workflows/dart.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v1
1212
- name: Install dependencies
13-
working-directory: bin/objectbox_model_generator
13+
working-directory: generator
1414
run: pub get
1515
- name: Run tests
16-
working-directory: bin/objectbox_model_generator
16+
working-directory: generator
1717
run: pub run test
1818

1919
lib:

CHANGELOG.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1+
0.4.0 (2019-10-31)
2+
------------------
3+
* Flutter Android support
4+
* Queries for all currently supported types
5+
(thanks [Jasm Sison](https://github.com/Buggaboo) for [#27](https://github.com/objectbox/objectbox-dart/pull/27) and [#46](https://github.com/objectbox/objectbox-dart/pull/46)]
6+
* More Box functions (count, isEmpty, contains, remove and their bulk variants)
7+
(thanks [liquidiert](https://github.com/liquidiert) for [#42](https://github.com/objectbox/objectbox-dart/pull/42) and [#45](https://github.com/objectbox/objectbox-dart/pull/45)]
8+
* Explicit write transactions
9+
(thanks [liquidiert](https://github.com/liquidiert) for [#50](https://github.com/objectbox/objectbox-dart/pull/50)]
10+
* Resolved linter issues
11+
(thanks [Gregory Sech](https://github.com/GregorySech) for [#31](https://github.com/objectbox/objectbox-dart/pull/31)]
12+
* Updated to objectbox-c 0.7.2
13+
* First release on pub.dev
14+
115
0.3.0 (2019-10-15)
216
------------------
317
* ID/UID generation and model persistence (objectbox-model.json)
418
* CI tests using GitHub Actions
519
* Code cleanup, refactoring and formatting
6-
(thanks [Buggaboo](https://github.com/Buggaboo) for [#20](https://github.com/objectbox/objectbox-dart/pull/20) & [#21](https://github.com/objectbox/objectbox-dart/pull/21)]
20+
(thanks [Jasm Sison](https://github.com/Buggaboo) for [#20](https://github.com/objectbox/objectbox-dart/pull/20) & [#21](https://github.com/objectbox/objectbox-dart/pull/21)]
721

822
0.2.0 (2019-09-11)
9-
------------------
23+
------------------Buggaboo
1024
* UTF-8 support for Store and Box
11-
(thanks to [Buggaboo](https://github.com/Buggaboo) for [#14](https://github.com/objectbox/objectbox-dart/pull/14)!)
25+
(thanks to [Jasm Sison](https://github.com/Buggaboo) for [#14](https://github.com/objectbox/objectbox-dart/pull/14)!)
1226
* Bulk put and get functions (getMany, getAll, putMany)
1327
* Updated to objectbox-c 0.7
1428
* Basic Store options

CONTRIBUTING.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Contributing
2+
------------------
3+
This project is completely managed on GitHub using its [issue tracker](https://github.com/objectbox/objectbox-dart/issues) and [project boards](https://github.com/objectbox/objectbox-dart/projects).
4+
5+
Anyone can contribute, be it by coding, improving docs or just proposing a new feature.
6+
Look for tasks having a [**"help wanted"**](https://github.com/objectbox/objectbox-dart/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) tag.
7+
When picking up an existing issue, please let us know in the issue comment.
8+
Don't hesitate to reach out for guidance or to discuss a solution proposal!
9+
10+
### Code contributions
11+
When creating a Pull Request for code changes, please check that you cover the following:
12+
* Include tests for the changes you introduce. See the [test folder](test) for examples.
13+
* Formatted the code using `dartfmt -l 120`. You can configure your IDE to do this automatically,
14+
e.g. VS Code needs the project-specific settings `"editor.defaultFormatter": "Dart-Code.dart-code"` and `"dart.lineLength": 120`.
15+
16+
### Project workflow
17+
Issues on the [project board](https://github.com/objectbox/objectbox-dart/projects/3) are referred to as "cards" which move from left to right:
18+
19+
* New cards start in the "To Do" column.
20+
Within the column, cards are ordered: more important tasks should be above less important ones.
21+
* Once somebody starts on a task, the according card is moved to "In progress".
22+
Also, please assign yourself to the issue.
23+
* Once a task is considered complete (e.g. PR is made), put it in the "Review" column.
24+
* Once another person had a look and is happy, the task is finally moved to "Done" and its closed.
25+
26+
### Basic technical approach
27+
ObjectBox offers a [C API](https://github.com/objectbox/objectbox-c) which can be called by [Dart FFI](https://dart.dev/server/c-interop).
28+
The C API is is also used by the ObjectBox language bindings for [Go](https://github.com/objectbox/objectbox-go), [Swift](https://github.com/objectbox/objectbox-swift), and [Python](https://github.com/objectbox/objectbox-python).
29+
These language bindings currently serve as an example for this Dart implementation.
30+
Internally, ObjectBox uses [FlatBuffers](https://google.github.io/flatbuffers/) to store objects.

README.md

Lines changed: 102 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,50 @@ ObjectBox for Dart/Flutter
22
==========================
33
ObjectBox for Dart is a standalone database storing Dart objects locally, with strong ACID semantics.
44

5-
Help wanted
6-
-----------
7-
ObjectBox for Dart is still in a prototype stage supporting only the most basic database tasks, like putting and getting objects.
8-
However, the ObjectBox core supports many more features, e.g. queries, indexing, async operations, transaction control.
9-
To bring all these features to Dart, we're asking the community to help out. PRs are more than welcome!
10-
The ObjectBox team will try its best to guide you and answer questions.
11-
12-
Contributing
13-
------------------
14-
This project is completely managed here on GitHub using its [issue tracker](https://github.com/objectbox/objectbox-dart/issues) and [project boards](https://github.com/objectbox/objectbox-dart/projects).
15-
16-
To prepare an upcoming version, we create a (Kanban like) board for it.
17-
Once it is decided which features and fixes go into the version, the according issues are added to the board.
18-
Issues on the board are referred to as "cards" which move from left to right:
19-
20-
* New cards start in the "To Do" column.
21-
Within the column, cards are ordered: more important tasks should be above less important ones.
22-
* Once somebody starts on a task, the according card is moved to "In progress".
23-
Also, please assign yourself to the issue.
24-
* Once a task is considered complete (e.g. PR is made), put it in the "Review" column.
25-
* Once another person had a look and is happy, the task is finally moved to "Done"
26-
27-
Anyone can contribute, be it by coding, improving docs or just proposing a new feature.
28-
Look for tasks having a **"help wanted"** tag.
29-
30-
#### Feedback
31-
Also, please let us know your feedback by opening an issue:
32-
for example, if you experience errors or if you have ideas for how to improve the API.
33-
Thanks!
5+
Installation
6+
------------
7+
Add the following dependencies to your `pubspec.yaml`:
8+
```yaml
9+
dependencies:
10+
objectbox: ^0.4.0
11+
12+
dev_dependencies:
13+
build_runner: ^1.0.0
14+
objectbox_generator: ^0.4.0
15+
```
3416
35-
#### Code style
36-
Please make sure that all code submitted via Pull Request is formatted using `dartfmt -l 120`.
37-
You can configure your IDE to do this automatically, e.g. VS Code needs the project-specific settings
38-
`"editor.defaultFormatter": "Dart-Code.dart-code"` and `"dart.lineLength": 120`.
17+
Proceed based on whether you're developing a Flutter app or a standalone dart program:
18+
1. **Flutter** only steps:
19+
* Install the packages `flutter pub get`
20+
* Add `objectbox-android` dependency to your `android/app/build.gradle`
21+
```
22+
dependencies {
23+
implementation "io.objectbox:objectbox-android:2.4.1"
24+
...
25+
```
26+
* iOS coming soon
27+
1. **Dart standalone programs**:
28+
* Install the packages `pub get`
29+
* Install [objectbox-c](https://github.com/objectbox/objectbox-c) system-wide:
30+
* macOS/Linux: execute the following command (answer Y when it asks about installing to /usr/lib)
31+
```shell script
32+
bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-c/master/download.sh) 0.7.2
33+
```
34+
* macOS: if dart later complains that it cannot find the `libobjectbox.dylib` you probably have to unsign the
35+
`dart` binary (source: [dart issue](https://github.com/dart-lang/sdk/issues/38314#issuecomment-534102841)):
36+
```shell script
37+
sudo xcode --remove-signature $(which dart)
38+
```
39+
* Windows: use "Git Bash" or similar to execute the following command
40+
```shell script
41+
bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-c/master/download.sh) 0.7.2
42+
```
43+
Then copy the downloaded `lib/objectbox.dll` to `C:\Windows\System32\` (requires admin privileges).
44+
45+
ObjectBox generates code binding code for classes you want stored based using build_runner.
46+
After you've defined your persisted entities (see below), run `pub run build_runner build` or `flutter pub run build_runner build`.
3947

4048
Getting started
41-
---------------
42-
To try out the demo code in this repository, follow these steps:
43-
44-
1. Install [objectbox-c](https://github.com/objectbox/objectbox-c) system-wide:
45-
* macOS/Linux: `bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-c/master/download.sh) 0.7` (answer Y when it asks about installing to /usr/lib).
46-
* Windows:
47-
* use "Git Bash" or similar to execute `bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-c/master/download.sh) 0.7`
48-
* copy the downloaded `lib/objectbox.dll` to `C:\Windows\System32\` (requires admin privileges)
49-
2. Back in this repository, run `pub get`.
50-
3. Execute `pub run build_runner build`. This regenerates the ObjectBox model to make it usable in Dart
51-
(i.e. the file `test/test.g.dart`) and is necessary each time you add or change a class annotated with `@Entity(...)`.
52-
4. Finally run `pub run test` to run the unit tests.
53-
54-
Dart integration
5549
----------------
5650
In general, Dart class annotations are used to mark classes as ObjectBox entities and provide meta information.
5751
Note that right now, only a limited set of types is supported; this will be expanded upon in the near future.
@@ -98,20 +92,70 @@ print("refetched note: ${box.get(note.id)}");
9892
store.close();
9993
```
10094

101-
Basic technical approach
102-
------------------------
103-
ObjectBox offers a [C API](https://github.com/objectbox/objectbox-c) which can be called by [Dart FFI](https://dart.dev/server/c-interop).
104-
The C API is is also used by the ObjectBox language bindings for [Go](https://github.com/objectbox/objectbox-go), [Swift](https://github.com/objectbox/objectbox-swift), and [Python](https://github.com/objectbox/objectbox-python).
105-
These language bindings currently serve as an example for this Dart implementation.
95+
### Query and QueryBuilder
96+
97+
Basic querying can be done with e.g.:
98+
99+
```dart
100+
// var store ...
101+
// var box ...
102+
103+
box.putMany([Note(), Note(), Note()]);
104+
box.put(Note.construct("Hello world!"));
105+
106+
final queryNullText = box.query(Note_.text.isNull()).build();
107+
108+
assert(queryNullText.count() == 3);
109+
110+
queryNullText.close(); // We have to manually close queries and query builders.
111+
```
112+
113+
More complex queries can be constructed using `and/or` operators.
114+
Also there is basic operator overloading support for `equal`, `greater`, `less`, `and` and `or`,
115+
respectively `==`, `>`, `<`, `&`, `|`.
116+
117+
```dart
118+
// final box ...
106119
107-
Internally, ObjectBox uses [FlatBuffers](https://google.github.io/flatbuffers/) to store objects.
108-
There are two basic ways to make the conversion: generated binding code, or implicit FlatBuffers conversion.
109-
The latter is used at the moment (helped us to get started quickly).
110-
A future version will exchange that with code generation.
120+
box.query(value.greaterThan(10).or(date.IsNull())).build();
121+
122+
// equivalent to
123+
124+
final overloaded = (value > 10) | date.IsNull();
125+
box.query(overloaded as Condition).build(); // the cast is necessary due to the type analyzer
126+
```
127+
128+
### Ordering
129+
130+
The results from a query can be ordered using the `order` method, e.g.
131+
132+
```dart
133+
final q = box.query(Entity_.number > 0)
134+
.order(Type_.number)
135+
.build();
136+
137+
// ...
138+
139+
final qt = box.query(Entity_.text.notNull())
140+
.order(Entity_.text, flags: OBXOrderFlag.DESCENDING | OBXOrderFlag.CASE_SENSITIVE)
141+
.build();
142+
```
143+
144+
Help wanted
145+
-----------
146+
ObjectBox for Dart is still in an early stage with limited feature set (compared to other languages).
147+
To bring all these features to Dart, we're asking the community to help out. PRs are more than welcome!
148+
The ObjectBox team will try its best to guide you and answer questions.
149+
150+
### Feedback
151+
Also, please let us know your feedback by opening an issue:
152+
for example, if you experience errors or if you have ideas for how to improve the API.
153+
Thanks!
111154

112-
Changelog
155+
See also
113156
---------
114-
[CHANGELOG.md](CHANGELOG.md)
157+
* [Changelog](CHANGELOG.md)
158+
* [Contribution guidelines](CONTRIBUTING.md)
115159

116160
License
117161
-------

analysis_options.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
include: package:pedantic/analysis_options.yaml
2+
3+
linter:
4+
rules:
5+
# additional rules used by pub.dev
6+
- non_constant_identifier_names
7+
8+
analyzer:
9+
exclude:
10+
- example/**
11+
- generator/** # needs to be checked separately because its a separate package

bin/objectbox_model_generator/lib/src/code_chunks.dart

Lines changed: 0 additions & 46 deletions
This file was deleted.

bin/objectbox_model_generator/pubspec.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

bin/objectbox_model_generator/test/cases/single_entity/single_entity.g.dart_expected

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)