Comments (6)
You can have a ?[]
together with a :create
in the same query. In addition, there are some utilities in the python client that allows you to do simple mutations:
db.put('rel_name', {'a': 1, 'b': 2})
db.put('rel_name', [{'a': 1, 'b': 2}, {'a':3, 'b': 4}])
The 'why' is that queries are not only hand-written, but also generated by machines (in fact in our own use, more queries are auto-generated). So reducing ambiguity is a priority. Reducing boilerplate is a job for language-specific clients.
from cozo.
This is also confusing:
:create test {name: String}
?[a] <- [['Cozo']]
:put test {a}
query::relation_not_found
× Cannot find requested stored relation 'test'
from cozo.
It seems like you cant create and put in the same query/transaction.
If you first run the create and then the put as separate queries it will work.
Or you can run multiple queries at once by wrapping them in curlybrackets.
This works:
{
:create test {name: String}
}
{
?[name] <- [['Cozo']]
:put test {name}
}
If you want to keep the a as binding name:
:create test {name: String}
?[a] <- [['Cozo']]
:put test {name=a}
from cozo.
Thanks for that.
I am still confused about a couple of things.
This works:
{
:create _test {name: String}
}
{
?[name] <- [['Cozo']]
:put _test {name}
}
So an ephemeral relation is within a single script, not a single transaction? I guess.
But why does this not work?
{
:create _test {name: String}
}
{
:put _test {['Cozo']'}
}
I tried 'Cozo', ['Cozo'] and [['Cozo']] and none of those worked.
from cozo.
You can't, these variables in :put
doesn't refer to a single value. It is working as expected.
If you are :create
ing, you can omit :put
while also have ?[a]
available and it will insert the value as documented here.
from cozo.
I don't understand the purpose of this restriction, it feels arbitrary. Why is binding to a variable required when there is only one possible value?
{
:create _test {name: String, kind: String}
}
{
:put _test {name: 'Cozo', kind: 'DB'}
}
# why can't this↑ be desugared to this↓ automatically?
{
?[name, kind] := name = 'Cozo', kind = 'DB'
:put _test {name, kind}
}
It works for querying, why not :put
?
{
:create _test {name: String, kind: String}
}
{
?[name, kind] := name = 'Cozo', kind = 'DB'
:put _test {name, kind}
}
{
?[kind] := *_test{name: 'Cozo', kind}
}
from cozo.
Related Issues (20)
- Missing documentation on `$` prefix for parameters HOT 11
- "Corrupted index" error when using the `bind_vector` option in hnsw index search HOT 5
- Cannot drop FTS index, it says it can't find it HOT 1
- How to start server on Windows? HOT 1
- SQL to Cozoscript mapping
- Can I uses embeddings for similarity search? HOT 1
- Review & comment on CozoDB tutorial/overview HOT 14
- Make Expr::eval_to_const public for FixedRule. HOT 1
- cozo-node - add support for BigInt
- Undirected KShortestPathYen does not produce results but ShortestPathDijkstra does HOT 1
- Trying to query FTS index with single quote fails
- Evaluating on VectorDBBench
- Jupyter Notebook inconsistent behavior
- Connect Swift CozoDB Client to standalone HTTP Server? HOT 3
- Extend CozoScript with ` allbut ` and ` select * ` projection operators HOT 1
- Problem with Rust regular expressions in CozoScript Regex functions HOT 2
- Importing/Indexing problem HOT 2
- Alternative storage engine, in memory data structure for CozoDB HOT 13
- Erlang NIF Implementation HOT 1
- Will there be support for collation ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cozo.