dpapathanasiou / simple-graph

This is a simple graph database in SQLite, inspired by "SQLite as a document database"
MIT License
1.4k stars 86 forks source link

how do i return the ID of the saved vertice ? #12

Closed afidegnum closed 2 years ago

afidegnum commented 3 years ago

is there a way to save a vertex and return it's id?

ope-nz commented 3 years ago

You supply the id, the database does not assign new ids.

dpapathanasiou commented 2 years ago

Hi @afidegnum and sorry for not getting back to you sooner

@ope-nz is right, part of the magic of this setup, using a generated column for the id means that you need to have defined it within the json body of the node, so you already "know" it.

But if all you're asking is how to have the id returned upon successful insert, similar to how RETURNING in PostgreSQL works, there's no built-in support for that in sqlite.

So instead, you could modify the functions to return it, if you want.