Skip to content

Commit

Permalink
fix: expand faableql
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Pomar committed Jan 11, 2024
1 parent 4c04696 commit b1919d5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
28 changes: 28 additions & 0 deletions src/faableql_multiple.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import test from "ava";
import { create_faableql } from "./faableql";

const faableQL = create_faableql([
{ name: "label", db: "labels" },
{ name: "category", db: "category" },
]);

// test("one field", (t) => {
// const query = faableQL("category:babies");
// t.deepEqual(query, {
// $and: [{ category: "babies" }],
// });
// });

test("one field as prefixed_id", (t) => {
const query = faableQL("category:tag_659d55daa7f446622dc4e1c3");
t.deepEqual(query, {
$and: [{ category: "tag_659d55daa7f446622dc4e1c3" }],
});
});

test("two different fields", (t) => {
const query = faableQL("category:tag_659d55daa7f446622dc4e1c3 label:hola");
t.deepEqual(query, {
$and: [{ category: "tag_659d55daa7f446622dc4e1c3" }, { labels: "hola" }],
});
});
4 changes: 2 additions & 2 deletions src/grammar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ FaableQL {
operator = (eq | noteq)
eq = ":"
noteq = "!:"
field = letter+
value = letter+
field = (alnum|"_"|"-")+
value = (alnum|"_"|"-")+
}
`;

Expand Down

0 comments on commit b1919d5

Please sign in to comment.