Skip to content

Rethink interfaces and how to deal with queries/responses #16

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

Open
niamtokik opened this issue Sep 10, 2023 · 1 comment
Open

Rethink interfaces and how to deal with queries/responses #16

niamtokik opened this issue Sep 10, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@niamtokik
Copy link
Owner

The current structure is simple, we generate a query from a string and receive the result as json. A more Erlangish way should be used.

@niamtokik niamtokik added the enhancement New feature or request label Sep 10, 2023
@niamtokik
Copy link
Owner Author

Some draft...

?[f1, f2, f3] <- [
  [1,2,3]
  [2, 3, 4]
]
:put test{f1, f2, f3}
-record(test, { f1 :: integer(), f2 :: integer(), f3 :: integer() }).

% create a new table using test record
cozo:create_table(Db, #test{}).

% create a list of data to insert
Data = [
  #test{ f1 = 1, f2 = 2, f3 = 3 },
  #test{ f1 = 2, f2 = 3, f3 = 4 }
].

% insert all data
cozo:put(Db, Data).

Types conversion from Erlang to Cozoscript (first)

Numbers

cozo_parse:from_erlang({ integer, 123 }).
%

cozo_parse:from_erlang({ float, 123.123 }).
%

cozo_parse:from_erlang({ number, 123 }).
% 
{integer, 123}
{float, 123.123}
{number, 123}
{list, [{integer, 123}]}
{string, <<"test">>}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant