2

I use Cassandra with Django via cqlengine. Let's assume I have a model like this:

class ExampleModel(Model):
    example_id      = columns.UUID(primary_key=True, default=uuid.uuid4)
    example_types   = columns.List(columns.Integer)
    example_other   = columns.Integer()

I create an object using the following code:

ex = ExampleModel.create(example_types=[1,2,3])

Somewhere else I want to update this row (eg. add some value to example_other) knowing it's example_id:

ex2 = ExampleModel.create(example_id=<this id I know>, example_other=5)

In the old version of cqlengine (0.4.6) it used to work, that is example_types stored in the database used to contain [1,2,3]. After an upgrade to 0.8.5 and after creating ex2, the same object stored in database has example_types set to an empty list. I understand that this is probably cleaner, but I want to be able to update row (alter particular column without altering rest of them) without having to fetch it first. How to achieve this? Thanks in advance!

k_wisniewski
  • 2,439
  • 3
  • 24
  • 31

1 Answers1

1

You can perform blind updates in cqlengine.

MyModel.objects(id=1).update(name="Steve")
Tim Martin
  • 2,419
  • 1
  • 21
  • 25