Skip to content
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

Adding an example of querying in C++ README #33

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ realm.write([&car](){
});
```

## Construct a Simple Query

Realm offers an expressive and intuitive way for querying data. Here's a simple example of querying for all `Person` objects and filtering the result based on age.

```cpp
int main() {
auto realm = realm::open<Person, Dog>({.path=path});
auto results = realm.objects<Person>().where("age > $0", {20});

return results.size();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Marcus - saw you put this up - it's nice to see an example of query here. For what it's worth, I and a couple other folks on the docs team have started working on building out docs for the C++ Alpha and have discovered there's some nuance to using the query results. It would be great to see an example here of doing something with the results, instead of just returning the size.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dacharyc done

}
```

## Building Realm

In case you don't want to use the precompiled version, you can build Realm yourself from source.
Expand Down