Skip to content
Open
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
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,26 @@ 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", {17});

for (const auto& person : results) {
std::string name = person.get_property<std::string>("name");
int age = person.get_property<int>("age");
std::string dogPurchasePower = (age >= 18) ? "can legally buy a dog in California" : "cannot legally buy a dog in California";
std::cout << "Customer " << name << " is " << age << " and " << dogPurchasePower << std::endl;
}

return 0;
}
```

## Building Realm

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