Skip to content

Commit

Permalink
- Upsert Replaced with Put
Browse files Browse the repository at this point in the history
  • Loading branch information
julfikar committed May 19, 2023
1 parent cdda64c commit fb1586e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flql"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
authors = ["Mohammad Julfikar <julfikar@eztech.com.my>", "Mohammad Julfikar <md.julfikar.mahmud@gmail.com>"]
categories = ["parser-implementations"]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ To use FLQL, you will need to have Flinch installed and running on your system.
`length('');` <br>
> Update or Insert into collection <br>
`upsert({}).into('');` <br>
`put({}).into('');` <br>
> Conditional Update or Insert into collection <br>
`upsert({}).when(:includes(array_filter('e.f$.g'),2):).into('');` <br>
`put({}).when(:includes(array_filter('e.f$.g'),2):).into('');` <br>
> Update or Insert into collection to a Pointer <br>
`upsert({}).pointer('').into('');` <br>
`put({}).pointer('').into('');` <br>
> Get from collection <br>
`get.from('');` <br>
Expand Down
12 changes: 6 additions & 6 deletions flql.pest
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ expr = {
drop |
exists |
length |
upsert |
upsert_when |
upsert_pointer |
put |
put_when |
put_pointer |
get |
get_when |
get_pointer |
Expand All @@ -26,9 +26,9 @@ drop = { "drop" ~ "(" ~ collection ~ ")" }
exists = { "exists" ~ "(" ~ pointer ~ ")"~"."~"into"~"(" ~ collection ~ ")" }
length = { "length"~"("~ collection ~ ")" }

upsert = { "upsert"~"(" ~ document ~ ")"~"."~"into"~"(" ~ collection ~ ")" }
upsert_when = { "upsert"~"("~document~")"~"."~"when"~"("~condition~")"~"."~"into"~"(" ~ collection ~ ")" }
upsert_pointer = { "upsert"~"("~document~")"~"."~"pointer"~"("~pointer~")"~"."~"into"~"(" ~ collection ~ ")" }
put = { "put"~"(" ~ document ~ ")"~"."~"into"~"(" ~ collection ~ ")" }
put_when = { "put"~"("~document~")"~"."~"when"~"("~condition~")"~"."~"into"~"(" ~ collection ~ ")" }
put_pointer = { "put"~"("~document~")"~"."~"pointer"~"("~pointer~")"~"."~"into"~"(" ~ collection ~ ")" }

get = { "get"~"."~"from"~"("~ collection ~")" }
get_when = { "get"~"."~"when"~"(" ~ condition ~ ")"~"."~"from"~"("~collection~")" }
Expand Down
48 changes: 24 additions & 24 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ use pest::iterators::{Pair};
/// `length('');` <br>
///
/// **Update or Insert into collection** <br>
/// `upsert({}).into('');` <br>
/// `put({}).into('');` <br>
///
/// **Conditional Update or Insert into collection** <br>
/// `upsert({}).when(:includes(array_filter('e.f$.g'),2):).into('');` <br>
/// `put({}).when(:includes(array_filter('e.f$.g'),2):).into('');` <br>
///
/// **Update or Insert into collection to a Pointer** <br>
/// `upsert({}).pointer('').into('');` <br>
/// `put({}).pointer('').into('');` <br>
///
/// **Get from collection** <br>
/// `get.from('');` <br>
Expand Down Expand Up @@ -66,9 +66,9 @@ use pest::iterators::{Pair};
/// "drop('');",
/// "exists('').into('');",
/// "length('');",
/// "upsert({}).into('');",
/// "upsert({}).when(:includes(array_filter('e.f$.g'),2):).into('');",
/// "upsert({}).pointer('').into('');",
/// "put({}).into('');",
/// "put({}).when(:includes(array_filter('e.f$.g'),2):).into('');",
/// "put({}).pointer('').into('');",
/// "get.from('');",
/// "get.when(:includes(array_filter('e.f$.g'),2):).from('');",
/// "get.pointer('').from('');",
Expand All @@ -90,9 +90,9 @@ use pest::iterators::{Pair};
/// Flql::Drop(_) => {}
/// Flql::Exists(_,_) => {}
/// Flql::Length(_) => {}
/// Flql::Upsert(_, _) => {}
/// Flql::UpsertWhen(_, _, _) => {}
/// Flql::UpsertPointer(_, _, _) => {}
/// Flql::Put(_, _) => {}
/// Flql::PutWhen(_, _, _) => {}
/// Flql::PutPointer(_, _, _) => {}
/// Flql::Get(_) => {}
/// Flql::GetWhen(_, _) => {}
/// Flql::GetPointer(_, _) => {}
Expand All @@ -119,9 +119,9 @@ pub enum Flql {
Drop(String),
Exists(String, String),
Length(String),
Upsert(String,String),
UpsertWhen(String, String, String),
UpsertPointer(String, String, String),
Put(String,String),
PutWhen(String, String, String),
PutPointer(String, String, String),
Get(String),
GetWhen(String, String),
GetPointer(String, String),
Expand Down Expand Up @@ -154,24 +154,24 @@ fn pair_parser(pair: Pair<Rule>) -> Flql {
Rule::length => {
Flql::Length(one(pair).to_string())
}
Rule::upsert => {
Rule::put => {
let two = two(pair);
Flql::Upsert(
Flql::Put(
two[0].to_string(),
two[1].to_string()
)
}
Rule::upsert_when => {
Rule::put_when => {
let three = three(pair);
Flql::UpsertWhen(
Flql::PutWhen(
three[0].to_string(),
three[1].to_string(),
three[2].to_string()
)
}
Rule::upsert_pointer => {
Rule::put_pointer => {
let three = three(pair);
Flql::UpsertPointer(
Flql::PutPointer(
three[0].to_string(),
three[1].to_string(),
three[2].to_string()
Expand Down Expand Up @@ -302,9 +302,9 @@ mod tests {
"drop('');",
"exists('').into('');",
"length('');",
"upsert({}).into('');",
"upsert({}).when(:includes(array_filter('e.f$.g'),2):).into('');",
"upsert({}).pointer('').into('');",
"put({}).into('');",
"put({}).when(:includes(array_filter('e.f$.g'),2):).into('');",
"put({}).pointer('').into('');",
"get.from('');",
"get.when(:includes(array_filter('e.f$.g'),2):).from('');",
"get.pointer('').from('');",
Expand All @@ -326,9 +326,9 @@ mod tests {
Flql::Drop(_) => {}
Flql::Exists(_,_) => {}
Flql::Length(_) => {}
Flql::Upsert(_, _) => {}
Flql::UpsertWhen(_, _, _) => {}
Flql::UpsertPointer(_, _, _) => {}
Flql::Put(_, _) => {}
Flql::PutWhen(_, _, _) => {}
Flql::PutPointer(_, _, _) => {}
Flql::Get(_) => {}
Flql::GetWhen(_, _) => {}
Flql::GetPointer(_, _) => {}
Expand Down

0 comments on commit fb1586e

Please sign in to comment.