0

I want to query a record which are having today's date. The cql code am trying is given below

cron = Cron.objects.filter(user_id = 5)
        cron= cron.filter(created_at__gte = datetime.combine(datetime.now().date(), datetime.min.time()))
        cron= cron.allow_filtering()
        result =  cron.first() 

I don't have today's record in the table, still am getting the record which are of yesterday in the query result.

Format of date in table is '2015-10-21 08:29:41-0400' (timestamp).

I don't find any reference for this case in cqlengine documents. If anyone can help that you would be great.

user4130072
  • 137
  • 4
  • 17

1 Answers1

0

In Cassandra you can not where bind or filter whatever you want there has some restriction in cassandra you query in a sequence order first partition key then clustering key.

you can query greater than today if your clustering key is timeuuid, deateime or date filed.

class Blog(Model):
   content_type = Text(partition_key=True)
   content_id = Date(primary_key=True)

query=Blog.object(content_type='article' and content_id__gte=datetime.now().date())

you can try this way

giasuddin
  • 133
  • 10