Skip to content

Commit

Permalink
Update code documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
greenrobot-team committed Oct 13, 2020
1 parent b212e2a commit 865ac18
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ query.close();
### Streams

Streams can be created from queries.
The streams can be extended with [rxdart](https://github.com/ReactiveX/rxdart);
Note: Dart Streams can be extended with [rxdart](https://github.com/ReactiveX/rxdart).

```dart
import "package:objectbox/src/observable.dart";
Expand Down
9 changes: 7 additions & 2 deletions lib/objectbox.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/// ObjectBox for Dart is a standalone database storing Dart objects locally,
/// with strong ACID semantics.
///
/// See the [README](https://github.com/objectbox/objectbox-dart#readme)
/// to get started.
library objectbox;

export 'src/annotations.dart';
export 'src/box.dart';
export 'src/common.dart';
export 'src/model.dart';
export 'src/store.dart';
export 'src/box.dart';
export 'src/modelinfo/index.dart';
export 'src/query/query.dart';
export 'src/store.dart';
14 changes: 12 additions & 2 deletions lib/src/query/query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,11 @@ class ConditionGroupAll extends ConditionGroup {
ConditionGroupAll(conditions) : super(conditions, bindings.obx_qb_all);
}

/// A repeatable Query returning the latest matching Objects.
///
/// Use [find] or related methods to fetch the latest results from the BoxStore.
///
/// Use [property] to only return values or an aggregate of a single Property.
class Query<T> {
Pointer<Void> _cQuery;
Store store;
Expand Down Expand Up @@ -599,6 +604,7 @@ class Query<T> {
checkObx(bindings.obx_query_limit(_cQuery, limit));
}

/// Returns the number of matching Objects.
int count() {
final ptr = allocate<Uint64>(count: 1);
try {
Expand All @@ -609,6 +615,7 @@ class Query<T> {
}
}

/// Close the query and free resources.
// TODO Document wrap with closure to fake auto close
void close() {
checkObx(bindings.obx_query_close(_cQuery));
Expand Down Expand Up @@ -681,12 +688,12 @@ class Query<T> {
});
}

// For testing purposes
/// For internal testing purposes.
String describe() {
return cString(bindings.obx_query_describe(_cQuery));
}

// For testing purposes
/// For internal testing purposes.
String describeParameters() {
return cString(bindings.obx_query_describe_params(_cQuery));
}
Expand Down Expand Up @@ -719,14 +726,17 @@ class Query<T> {
}
}

/// See [property] for details.
IntegerPropertyQuery integerProperty(QueryProperty qp) {
return property<IntegerPropertyQuery>(qp);
}

/// See [property] for details.
DoublePropertyQuery doubleProperty(QueryProperty qp) {
return property<DoublePropertyQuery>(qp);
}

/// See [property] for details.
StringPropertyQuery stringProperty(QueryProperty qp) {
return property<StringPropertyQuery>(qp);
}
Expand Down
16 changes: 16 additions & 0 deletions lib/src/store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ class Store {
Pointer<Void> _cStore;
final ModelDefinition defs;

/// Creates a BoxStore using the model definition from your
/// `objectbox.g.dart` file.
///
/// For example in a Dart app:
/// ```
/// var store = Store(getObjectBoxModel());
/// ```
///
/// Or for a Flutter app:
/// ```
/// getApplicationDocumentsDirectory().then((dir) {
/// _store = Store(getObjectBoxModel(), directory: dir.path + "/objectbox");
/// });
/// ```
///
/// See our examples for more details.
Store(this.defs,
{String directory, int maxDBSizeInKB, int fileMode, int maxReaders}) {
var model = Model(defs.model);
Expand Down

0 comments on commit 865ac18

Please sign in to comment.