Back

How to query updated documents - Swift?

  • 0
  • Apple
Ranga Reddy
28 Sep, 2024, 19:32

Should retrieve modified documents of a specified type from the Appwrite database by querying the timestamp.

TypeScript
func fetchModifiedDocuments<T: Codable>(
        collectionId: String,
        since timestamp: TimeInterval
    ) async throws -> [AppwriteModels.Document<T>] {
        do {
            let query = Query.greaterThan("$updatedAt", value: timestamp)
            let documents = try await databases.listDocuments(
                databaseId: AppwriteConstants.DATABASE_ID,
                collectionId: collectionId,
                queries: [query],
                nestedType: T.self
            )
            
            return documents.documents
        } catch {
            print("Error fetching modified documents: \(error.localizedDescription)")
            throw error
        }
    }

Error

Error fetching modified documents: Invalid query: Query value is invalid for attribute "$updatedAt" Error fetching decks: Invalid query: Query value is invalid for attribute "$updatedAt"

TL;DR
Fetch modified documents of a specific type from the Appwrite database by querying the timestamp. Error: Query value is invalid for the "$updatedAt" attribute. Solution: Ensure the query value is appropriate for the "$updatedAt" attribute when querying for modified documents in Swift.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more