set
async def set(self, name: str, items=list[dict]|dict, start=0) -> None:
| Param | Description |
|---|---|
| name | Name of the list |
| items | - Single item: dictionary - Multiple times: A list of dictionaries |
| start | Position to start setting |
Overwrite existing node(s).
Raises
ResponseErrornamedoes not exist
ValueErrorstart < 0
TypeErroritemsis notdictorlist
Examples
client = NdbClient()
await client.open('ws://127.0.0.1:1987/')
# create API object
lists = ObjLists(client)
await lists.create('books')
await lists.add('books', [{'title':'Harry Potter'}, {'title':'Moby Dick'}, {'title':'War and Peace'}])
print(await lists.get_rng('books', start=0))
# overwrite Moby Dick
await lists.set('books', {'title':'Dracula'}, start=1)
print(await lists.get_rng('books', start=0))
[{'title': 'Harry Potter'}, {'title': 'Moby Dick'}, {'title': 'War and Peace'}]
[{'title': 'Harry Potter'}, {'title': 'Dracula'}, {'title': 'War and Peace'}]