diff --git a/:q b/:q new file mode 100644 index 0000000..732366e --- /dev/null +++ b/:q @@ -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 diff --git a/engine/actions.go b/engine/actions.go index 04403e5..d623e84 100644 --- a/engine/actions.go +++ b/engine/actions.go @@ -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": diff --git a/engine/aggregate.go b/engine/aggregate.go index ea3ce79..e362702 100644 --- a/engine/aggregate.go +++ b/engine/aggregate.go @@ -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 { @@ -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{} diff --git a/engine/queries.go b/engine/queries.go index 80252cb..c724c07 100644 --- a/engine/queries.go +++ b/engine/queries.go @@ -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 @@ -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 @@ -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 @@ -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 @@ -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() == "" { @@ -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 ? @@ -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 { @@ -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 @@ -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 = "" @@ -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 @@ -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) @@ -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"}` }