Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
baxiry committed Jul 1, 2024
1 parent ce17bb8 commit c9abecc
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 18 deletions.
31 changes: 31 additions & 0 deletions :q
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Updated. Elapsed time: 317.433125 sec.
[==================x]

- Finishing ... Done!
- Post-update hook for coc-eslint ... OK
- Post-update hook for coc-tsserver ... OK
- Post-update hook for coc-highlight ... OK
- Post-update hook for coc-prettier ... OK
- Post-update hook for coc-css ... OK
- Post-update hook for coc-lists ... OK
x Post-update hook for coc-tslint ... Exit status: 1
- Post-update hook for coc-snippets ... OK
- papercolor-theme: Already installed
- fzf: Already installed
- coc-eslint: Resolving deltas: 100% (172/172), done.
- coc-tslint: Resolving deltas: 100% (55/55), done.
- coc-highlight: Resolving deltas: 100% (103/103), done.
- coc.nvim: Already installed
- tokyonight.nvim: Already installed
- coc-prettier: Resolving deltas: 100% (221/221), done.
- onedarkpro.nvim: Already installed
- gitsigns.nvim: Already installed
- coc-css: Resolving deltas: 100% (97/97), done.
- gocode: Already installed
- vim-airline-themes: Already installed
- catppuccin: Already installed
- coc-lists: Resolving deltas: 100% (297/297), done.
- vim-moonfly-colors: Already installed
- coc-snippets: Resolving deltas: 100% (750/750), done.
- coc-tsserver: Resolving deltas: 100% (1311/1311), done.
- vim-airline: Already installed
2 changes: 1 addition & 1 deletion engine/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
// ok
func HandleQueries(query string) string {
parsedQuery := gjson.Parse(query)
switch parsedQuery.Get("action").String() {
switch parsedQuery.Get("a").String() { // action

// database actions
case "findOne":
Expand Down
7 changes: 6 additions & 1 deletion engine/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import (

const siparator = "_:_"

func orderBy(param string, data []gjson.Result) []gjson.Result {

return data
}

// reKey renames json feild
func reKey(oldkey, newkey, json string) string {

Expand Down Expand Up @@ -47,7 +52,7 @@ func reKey(oldkey, newkey, json string) string {
}

// fields remove or rename fields
func fields(data []string, fields gjson.Result) []string {
func reFields(data []string, fields gjson.Result) []string {

newKey := []string{}
oldKey := []string{}
Expand Down
32 changes: 16 additions & 16 deletions engine/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ type matched struct {
// deletes Many items
func (db *DB) deleteMany(query gjson.Result) string {

mtch := query.Get("match")
mtch := query.Get("m")

coll := query.Get("collection").String()
coll := query.Get("c").String()

stmt := `select rowid, record from ` + coll

Expand Down Expand Up @@ -64,11 +64,11 @@ func (db *DB) deleteMany(query gjson.Result) string {
// TODO updateMany update document data
func (db *DB) updateMany(query gjson.Result) (result string) {

mtch := query.Get("match")
mtch := query.Get("m")

newObj := query.Get("data").String()

coll := query.Get("collection").String()
coll := query.Get("c").String()

// updates exist value

Expand Down Expand Up @@ -121,11 +121,11 @@ func (db *DB) updateMany(query gjson.Result) (result string) {
// TODO updateOne one update document data
func (db *DB) updateOne(query gjson.Result) (result string) {

mtch := query.Get("match")
mtch := query.Get("m")

newObj := query.Get("data").String()

coll := query.Get("collection").String()
coll := query.Get("c").String()

// updates exist value

Expand Down Expand Up @@ -175,7 +175,7 @@ func (db *DB) updateById(query gjson.Result) (result string) {

id := query.Get("_id").String()
newObj := query.Get("data").String()
coll := query.Get("collection").String()
coll := query.Get("c").String()

newData := gjson.Get(`[`+oldObj+`,`+newObj+`]`, `@join`).Raw

Expand All @@ -195,12 +195,12 @@ func (db *DB) updateById(query gjson.Result) (result string) {
func (db *DB) findMany(query gjson.Result) (res string) {

// TODO parse hol qury one time
coll := query.Get("collection").String()
coll := query.Get("c").String()
if coll == "" {
return `{"error":"forgot collection name "}`
}

mtch := query.Get("match")
mtch := query.Get("m")

if mtch.String() == "" {

Expand Down Expand Up @@ -270,7 +270,7 @@ func (db *DB) findMany(query gjson.Result) (res string) {

// Finds first obj match creteria.
func (db *DB) findOne(query gjson.Result) (res string) {
coll := query.Get("collection").String()
coll := query.Get("c").String()
skip := query.Get("skip").Int()

// TODO are skyp useful here ?
Expand All @@ -283,7 +283,7 @@ func (db *DB) findOne(query gjson.Result) (res string) {
}
defer rows.Close()

mtch := query.Get("match")
mtch := query.Get("m")
record := ""
for rows.Next() {
if skip != 0 {
Expand All @@ -310,7 +310,7 @@ func (db *DB) findOne(query gjson.Result) (res string) {
// delete
func (db *DB) deleteOne(query gjson.Result) string {

coll := query.Get("collection").String()
coll := query.Get("c").String()

stmt := `select rowid, record from ` + coll

Expand All @@ -321,7 +321,7 @@ func (db *DB) deleteOne(query gjson.Result) string {

rowid := "0"
record := ""
mtch := query.Get("match")
mtch := query.Get("m")
for rows.Next() {
record = ""
rowid = ""
Expand Down Expand Up @@ -352,7 +352,7 @@ func (db *DB) deleteOne(query gjson.Result) string {

// Finds first obj match creteria.
func (db *DB) findById(query gjson.Result) (res string) {
coll := query.Get("collection").String()
coll := query.Get("c").String()
id := query.Get("_id").String()

stmt := `select record from ` + coll + ` where rowid = ` + id
Expand Down Expand Up @@ -380,7 +380,7 @@ func (db *DB) findById(query gjson.Result) (res string) {

// Insert
func (db *DB) insertOne(query gjson.Result) (res string) {
coll := query.Get("collection").String()
coll := query.Get("c").String()
data := query.Get("data").String()

err := db.insert(coll, data)
Expand All @@ -397,7 +397,7 @@ func (db *DB) deleteById(query gjson.Result) string {
if id == "" {
return `{"error": "there is no _id"}`
}
coll := query.Get("collection").String()
coll := query.Get("c").String()
if coll == "" {
return `{"error": "there is no collection"}`
}
Expand Down

0 comments on commit c9abecc

Please sign in to comment.