You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Implement extensions to ParseQuery to use property's name as key instead of strings
Signed-off-by: Daniel San <[email protected]>
* Update README to show ParseQuery extensions
Signed-off-by: Daniel San <[email protected]>
Copy file name to clipboardExpand all lines: ktx/README.md
+24-1Lines changed: 24 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,6 +75,29 @@ The `stringAttribute` is a property delegate, and we have many other specialized
75
75
76
76
This causes us to not have to write get/set and besides, it removed the get/put boilerplate which is a must to map our classes with the Parse collections.
77
77
78
+
## ParseQuery extensions
79
+
80
+
Using Property Delegates will allow you to use a more secure way of creating queries.
81
+
82
+
If is needed to rename some property of a ParseObject, it is only necessary to use the IDE refactoring tool, that your queries will be automatically updated, which is not the case if hard coded strings are used.
83
+
84
+
```kotlin
85
+
@ParseClassName("Cat")
86
+
classCat : ParseObject() {
87
+
88
+
var age by intAttribute()
89
+
90
+
}
91
+
92
+
val query =ParseQuery.getQuery(Cat::class.java)
93
+
// Use this syntax
94
+
query.whereEqualTo(Cat::name, 1)
95
+
// instead of
96
+
query.whereEqualTo("age", 1)
97
+
// or
98
+
query.whereEqualTo(Cat::age.name, 1)
99
+
```
100
+
78
101
## Contributing
79
102
When contributing to the `ktx` module, please first consider if the extension function you are wanting to add would potentially be better suited in the main `parse` module. If it is something specific to Kotlin users or only useful in a Kotlin project, feel free to make a PR adding it to this module. Otherwise, consider adding the addition to the `parse` module itself, so that it is still usable in Java.
80
103
@@ -84,4 +107,4 @@ When contributing to the `ktx` module, please first consider if the extension fu
84
107
85
108
This source code is licensed under the BSD-style license found in the
86
109
LICENSE file in the root directory of this source tree. An additional grant
87
-
of patent rights can be found in the PATENTS file in the same directory.
110
+
of patent rights can be found in the PATENTS file in the same directory.
0 commit comments