I have been doing some work with the API and I have found the
following problem:
Currently I have my objects that returns a dictionary(get_object_data
method) in order to easily serialize it in to a JSON object. This work
perfectly when creating a new doc. The problem I found is when I want
to update a doc in the database doing the following:
# add object
person.id = db.create(person.get_object_data())
person.name = "test"
doc = db[person.id]
# I get all the data because although in the example I just changed
name, thee are cases where more is changed.
doc = person.get_object_data()
Bare in mind that the dict returned bey )get)object_data is usually
like this:
> I have been doing some work with the API and I have found the > following problem:
> Currently I have my objects that returns a dictionary(get_object_data > method) in order to easily serialize it in to a JSON object. This work > perfectly when creating a new doc. The problem I found is when I want > to update a doc in the database doing the following:
> # add object > person.id = db.create(person.get_object_data()) > person.name = "test" > doc = db[person.id] > # I get all the data because although in the example I just changed > name, thee are cases where more is changed. > doc = person.get_object_data()
> Bare in mind that the dict returned bey )get)object_data is usually > like this:
> Which I find very odd, > can anyone give me a hand with this.
It's quite difficult to help because your example doesn't actually call Database.update(docs) anywhere.
However, from the exception, it looks like one of the documents you passed to update is a string (a str instance). Each document must be either a dict (or subclass) instance or something with a dict-like items() method.