diff --git a/README.md b/README.md index cd80d9cf..69960b32 100644 --- a/README.md +++ b/README.md @@ -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({.path=path}); + auto results = realm.objects().where("age > $0", {17}); + + for (const auto& person : results) { + std::string name = person.get_property("name"); + int age = person.get_property("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.