0

I have an ArangoDB collection containing some documents. I need to get one of them, add or update some data and save it.

To get the document, I use Document _key field on Collection instance:

doc = collection[key]

Then, I update with a dict data:

for k, v in data.items():
    doc[k] = v

finally, I save it

doc.save()

Unfortunately some of the int are converted to string

Juste before saving:

enter image description here

And when I reload it with doc2 = collection[key]:

enter image description here

From what I'm seeing, I guess I could convert all int to float before saving, but it's kind of messy.

What am I doing wrong?

Cyrille
  • 13,905
  • 2
  • 22
  • 41

1 Answers1

0

Well, it turns out, some int where in fact numpy.int64 and pyarango handle them as string

I simple int(value) if isinstance(value, np.int64) else value fixed this issue (called recursively in my case, using this answer).

Cyrille
  • 13,905
  • 2
  • 22
  • 41