Closed JapendWFM closed 5 years ago
@JapendWFM If I understand your code correctly the loop below will execute only once for the sample input you provided:
for key, item in ipairs(petition.items) do
newItem ={collection = glo.ITEM_COLLECTION_NAME, key = item.key, value = item.data, user_id = nil, permission_read = 2, permission_write = 0}
nk.storage_write({newItem})
end
And will attempt to write a single storage record with the key cars
and the value [{"item_id":"CAR01",[...snip...]}]
.
Is this what you intended to do?
If so it won't quite work because the storage value you're attempting to write is a top-level JSON array ([]
). The storage system currently only allows top-level JSON objects ({}
).
Yes, that is what I was intending to do with that code.
In that case I think this is a duplicate of the feature request in #304. Keep an eye on that, but until then you can change your data structure to be a top-level JSON object.
Description
When trying to add multiple items to a public colection in the server using an rcp call that is being called from a test html we found that the collection is created with the correct key, but with no value.
However, if we (using the same code) access one of the provided values (like data[1]), then hat value is written.
Steps to Reproduce
1. Send the payload:
2. In server, execute the function add_items. It will try to write and read afterwards, to check if everything went ok:
3. Try again, but adding only one value this time
Expected Result
In step 2, collection with corresponding keys should contain all provided values. In step 3, collection with corresponding key should contain only one value.
Actual Result
For code in step 2:
For code in step 3:
Your Environment