Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update create API #4688

Merged
merged 1 commit into from
Sep 4, 2024
Merged

Update create API #4688

merged 1 commit into from
Sep 4, 2024

Conversation

rushmorem
Copy link
Collaborator

@rushmorem rushmorem commented Sep 4, 2024

What is the motivation?

#4667 made sure create always returns a single object.

What does this change do?

This is a followup to that PR to make sure the API always expects a single record. To create on a record ID, one does

let person: Option<Person> = db.create(("person", "tobie")).await?;

This hasn't changed. To call create on a table we used to do

let person: Vec<Person> = db.create("person").await?;

This is what has changed. Now we do

let person: Option<Person> = db.create("person").await?;

Notice the difference in return type.

We had an opportunity here to go back to what we were doing before v1.

let person: Person = db.create("person").await?;

This would have been nice but then code like

db.create("person").await?;

would compile fine because in that case, Rust infers the return type to be a unit.

What is your testing strategy?

Github Actions.

Is this related to any issues?

  • No related issues

Does this change need documentation?

surrealdb/docs.surrealdb.com#820

Have you read the Contributing Guidelines?

@rushmorem rushmorem marked this pull request as ready for review September 4, 2024 12:33
@rushmorem rushmorem requested review from tobiemh and a team as code owners September 4, 2024 12:33
@tobiemh tobiemh merged commit 29c6914 into surrealdb:main Sep 4, 2024
23 checks passed
@rushmorem rushmorem deleted the create-api branch September 4, 2024 12:51
@rushmorem rushmorem added this to the v2.0.0-beta.2 milestone Sep 4, 2024
@Dhghomon Dhghomon mentioned this pull request Nov 5, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants