|
|
@@ -8,9 +8,10 @@
|
|
|
|
|
|
#import "FLEXRealmDatabaseManager.h"
|
|
|
|
|
|
-//#if __has_include("<Realm/Realm.h>")
|
|
|
+#if __has_include("<Realm/Realm.h>")
|
|
|
|
|
|
#import <Realm/Realm.h>
|
|
|
+#import <Realm/RLMRealm_Dynamic.h>
|
|
|
|
|
|
@interface FLEXRealmDatabaseManager ()
|
|
|
|
|
|
@@ -19,8 +20,12 @@
|
|
|
|
|
|
@end
|
|
|
|
|
|
+#endif
|
|
|
+
|
|
|
@implementation FLEXRealmDatabaseManager
|
|
|
|
|
|
+#if __has_include("<Realm/Realm.h>")
|
|
|
+
|
|
|
- (instancetype)initWithPath:(NSString*)aPath
|
|
|
{
|
|
|
self = [super init];
|
|
|
@@ -62,14 +67,40 @@
|
|
|
|
|
|
- (NSArray *)queryAllColumnsWithTableName:(NSString *)tableName
|
|
|
{
|
|
|
- return nil;
|
|
|
+ RLMObjectSchema *objectSchema = [self.realm.schema schemaForClassName:tableName];
|
|
|
+ if (objectSchema == nil) {
|
|
|
+ return nil;
|
|
|
+ }
|
|
|
+
|
|
|
+ NSMutableArray *columnNames = [NSMutableArray array];
|
|
|
+ for (RLMProperty *property in objectSchema.properties) {
|
|
|
+ [columnNames addObject:property.name];
|
|
|
+ }
|
|
|
+
|
|
|
+ return columnNames;
|
|
|
}
|
|
|
|
|
|
- (NSArray *)queryAllDataWithTableName:(NSString *)tableName
|
|
|
{
|
|
|
- return nil;
|
|
|
+ RLMObjectSchema *objectSchema = [self.realm.schema schemaForClassName:tableName];
|
|
|
+ RLMResults *results = [self.realm allObjects:tableName];
|
|
|
+ if (results.count == 0 || objectSchema == nil) {
|
|
|
+ return nil;
|
|
|
+ }
|
|
|
+
|
|
|
+ NSMutableArray *allDataEntries = [NSMutableArray array];
|
|
|
+ for (RLMObject *result in results) {
|
|
|
+ NSMutableDictionary *entry = [NSMutableDictionary dictionary];
|
|
|
+ for (RLMProperty *property in objectSchema.properties) {
|
|
|
+ entry[property.name] = [result valueForKey:property.name];
|
|
|
+ }
|
|
|
+
|
|
|
+ [allDataEntries addObject:entry];
|
|
|
+ }
|
|
|
+
|
|
|
+ return allDataEntries;
|
|
|
}
|
|
|
|
|
|
-@end
|
|
|
+#endif
|
|
|
|
|
|
-//#endif
|
|
|
+@end
|