Selaa lähdekoodia

new tablePhotoLibrary

Marino Faggiana 7 vuotta sitten
vanhempi
commit
d55900dbae
2 muutettua tiedostoa jossa 44 lisäystä ja 0 poistoa
  1. 10 0
      iOSClient/Database/NCDatabase.swift
  2. 34 0
      iOSClient/Database/NCManageDatabase.swift

+ 10 - 0
iOSClient/Database/NCDatabase.swift

@@ -204,6 +204,16 @@ class tableMetadata: Object {
     }
 }
 
+class tablePhotoLibrary: Object {
+    
+    dynamic var account = ""
+    dynamic var assetLocalIdentifier = ""
+    
+    override static func primaryKey() -> String {
+        return "assetLocalIdentifier"
+    }
+}
+
 class tableShare: Object {
     
     dynamic var account = ""

+ 34 - 0
iOSClient/Database/NCManageDatabase.swift

@@ -1884,6 +1884,40 @@ class NCManageDatabase: NSObject {
     }
     */
     
+    
+    //MARK: -
+    //MARK: Table Photo Library
+    
+    func addPhotoLibrary(_ photosVideos: [tablePhotoLibrary]) {
+        
+        let realm = try! Realm()
+        
+        do {
+            try realm.write {
+                
+                for tablePhotoLibrary in photosVideos {
+                    realm.add(tablePhotoLibrary, update: true)
+                }
+            }
+        } catch let error {
+            print("Could not write to database: ", error)
+        }
+    }
+    
+    func getPhotoLibrary() -> [tablePhotoLibrary]? {
+        
+        let tableAccount = self.getAccountActive()
+        if tableAccount == nil {
+            return nil
+        }
+        
+        let realm = try! Realm()
+        
+        let results = realm.objects(tablePhotoLibrary.self).filter("account = %@", tableAccount!.account)
+        
+        return Array(results)
+    }
+
     //MARK: -
     //MARK: Table Share