Back

Facing issue with querying the database "$createdAt"

  • 1
  • Self Hosted
  • Databases
Abhishek
17 Sep, 2024, 20:34

I'm using python appwrite function.

Error: appwrite.exception.AppwriteException: Invalid query: Attribute not found in schema: _createdAt

Code:

TypeScript
results = Databases(client).list_documents('DATABASE', 'COLLECTION', [
                Query.and_queries([
                    Query.equal('id', [user['$id']]),
                    Query.between('$createdAt', start_iso, end_iso)
                ])
            ])

For date conversion: datetime.now().isoformat()

TL;DR
Developers facing a database query issue with "$createdAt" attribute. In the Python SDK v5.0.3, they expect to use `and_queries` while the documentation only mentions `and`. The error indicates an "Attribute not found in schema: $createdAt." Solution: Ensure correct attribute naming convention, using `$createdAt` instead of `_createdAt`.
Kenny
17 Sep, 2024, 20:38

Is it not just and? In the docs I'm not seeing and_queries

TypeScript
Query.and([
  Query.equal('id', [user['$id']]),
  Query.between("$createdAt", start_iso, end_iso)
])
Abhishek
17 Sep, 2024, 20:41

I'm on v1.5.7 self-hosted appwrite version. Using python sdk v5.0.3

Abhishek
17 Sep, 2024, 20:43
Abhishek
17 Sep, 2024, 20:45

I just checked even in Python SDK v6.1.0; it's the same. However, the documentation has and only

Abhishek
17 Sep, 2024, 20:47

I think the documentation is incorrect. In Python, or and and are built-in keywords.

Abhishek
17 Sep, 2024, 20:54

Facing issue with querying the database "$createdAt"

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