Skip to content

Commit

Permalink
improve docs 'matching text'
Browse files Browse the repository at this point in the history
  • Loading branch information
baxiry committed Jun 22, 2024
1 parent 0ce5a4f commit 009a717
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 22 deletions.
58 changes: 36 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@


**ZaraDB:** A Lightweight fast document database
**ZaraDB:**
A Lightweight fast document database

ZaraDB is a lightweight fast open-licensed document database with no hidden restrictions.
Its goal is to be a lightweight alternative to common documentary databases.
Expand All @@ -20,42 +21,40 @@ go get github.com/baxiry/zaradb && cd zaradb && go build .
```


***API Documentation***:
**API Documentation**:

## Note
Zara receives queries in JSON format. But you can use JavaScript objects through the web interface provided by Zara via: ` localhost:1111 `


**Insert**

* **Insert one data object:**
**Insert one data object:**


```js
{action:"insert", collection:"users", data:{name:"adam", age:23}}
```

* **Insert many data objects (bulk):**
**Insert many data objects (bulk):**

```js
{action:"insertMany", collection:"users", data:[{name:"jalal", age:23},{name:"akram", age:30},{name:"hasna", age:35}]}
```

**Selecte**

* **Select one object:**
***Select one object:***

```js
{action:"findOne", collection:"users", match:{name:"adam"}}
```

* **Select objects matching conditions:**
**Select objects matching conditions:**

```js
{action:"findMany", collection:"users", match:{name:"adam"}}
```

* **Select objects matching specific conditions:**
**Select objects matching specific conditions:**

```js
{action:"findMany", collection:"users", match:{name:"adam", age:{$gt:12}}}
Expand All @@ -64,7 +63,7 @@ Zara receives queries in JSON format. But you can use JavaScript objects through
Supported comparison operators: $eq (equal), $nq (not equal), $lt (less than), $gt (greater than), $ge (greater than or equal to), $le (less than or equal to)


* **Select objects matching any value in list:**
**Select objects matching any value in list:**

```js
// number list
Expand All @@ -76,7 +75,7 @@ Supported comparison operators: $eq (equal), $nq (not equal), $lt (less than), $
{action:"findMany", collection:"users", match:{ name:{$in:["akram", "zaid"]}}}
```

* **Select objects that do not match any value in list:**
**Select objects that do not match any value in list:**

```js
// number list
Expand All @@ -88,67 +87,82 @@ Supported comparison operators: $eq (equal), $nq (not equal), $lt (less than), $
{action:"findMany", collection:"users", match:{ name:{$nin:["akram", "zaid"]}}}
```

* **Select objects matching any conditions by $or operator:**
**Select objects matching any conditions by $or operator:**

```js
{action:"findMany", collection:"users", match:{ $or:[name:{$eq:"akram", age:$gt:13}]}}
```

* **Select objects matching all conditions by $and operator:**
**Select objects matching all conditions by $and operator:**

```js
{action:"findMany", collection:"users", match:{ $and:[name:{$eq:"akram", age:$gt:13}]}}
```

**Update**

* **Update by ID:**
**Update by ID:**

```js
{action:"updateById", collection:"users", _id:3, data:{name:"hosam", age:10}}
```

* **Update one or more documents matching criteria:**
**Update one or more documents matching criteria:**

```js
{action:"updateOne", collection:"users", match:{_id{$gt:33}}, data:{name:"hosam", age:10}}
```

**Delete**

* **Delete the first document matching conditions:**
**Delete the first document matching conditions:**

```js
{action:"deleteOne", collection:"users", match:{name:"adam", age:{$gt:12}}}
```

* **Delete all objects matching conditions:**
**Delete all objects matching conditions:**

```js
{action:"deleteMany", collection:"users", match:{name:"adam", age:{$gt:12}}}
```

* **Skip or ignore some first N matching objects:**
**Skip or ignore some first N matching objects:**

```js
{action:"deleteMany", collection:"users", match:{name:"adam", age:{$gt:12}}, skip: 3}
```

* **Delete a limited number of matching objects:**
**Delete a limited number of matching objects:**

```js
{action:"deleteMany", collection:"users", match:{name:"adam", age:{$gt:12}}, skip: 3, limit:3}
```

* **Exclude fields during retrieval:**
**Exclude fields during retrieval:**

```js
{action:"findMany", collection:"users", fields:{_id:0, name:0}}
```

* **Rename fields during retrieval:**
**Rename fields during retrieval:**

```js
{action:"findMany", collection:"users", fields:{_id:0, name:"full_name"}}
```

**String matching, by `$st` `$en` `$c` :**

is str starts with 'ad':
```js
{action:"findMany", collection:"test", match:{name:{$st:"ad"}}}
```

is str ends with 'ad':
```js
{action:"findMany", collection:"test", match:{name:{$en:"ad"}}}
```

is str contains 'ad':
```js
{action:"findMany", collection:"test", match:{name:{$c:"ad"}}}
```
12 changes: 12 additions & 0 deletions static/shell.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ <h4>examples</h4>
<p>rename fields</p>
{action:"findMany", collection:"test", fields:{_id:0, name:"full_name"}}


<p>String matching, by `$st` `$en` `$c` :</p>

<p>is str starts with 'ad' ? :</p>
{action:"findMany", collection:"test", match:{name:{$st:"ad"}}}

<p>is str ends with 'ad' ? :</p>
{action:"findMany", collection:"test", match:{name:{$en:"ad"}}}

<p>is str contains 'ad' ? :</p>
{action:"findMany", collection:"test", match:{name:{$c:"ad"}}}

<br/>
<br/>
<br/>
Expand Down

0 comments on commit 009a717

Please sign in to comment.