surrealdb/surrealdb.py

create_all vs create_one

omrihaber opened this issue · 3 comments

I think there are 2 redundant functions:

In the current implementation the difference between create_all and create_one
is the provision of id.
But create_all implies that we can provide more than 1 entry.

In both CREATE methods I would expect the provision of id to be optional.
additionally can we provide examples/usage of inserting more than 1 entry?

this is an issue with the REST API rather than the lib code.

create_all does allow for multiple entries (pass it a list of objects), while create_one doesn't. due to the query that create_all runs on the API side, you cannot provision IDs for that function yet but this is an issue to raise on the main surrealdb repo.

due to way these endpoints work, i also cannot make id optional as their usecase is specific to records.

i recommend using the websockets client instead, it has more features & will likely solve the issues you are facing

create_all does allow for multiple entries (pass it a list of objects)

yeah, but CREATE method which is triggered on API side not allow for adding multiple records... So IMO by now that name is confusing.

This has now been resolved in the latest PR
Where we now have just one create method, which accepts either just a table or a table with an id.
You can see that in the documentation that was just released