New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/kishieel/couchdb-query-server-go

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/kishieel/couchdb-query-server-go

  • v0.0.0-20240610214542-8aa8c21f24fc
  • Source
  • Go
  • Socket score

Version published
Created
Source

CouchDB Query Server Go

The CouchDB Query Server Go is a Go implementation of the CouchDB Query Server protocol for CouchDB 3.3.0 or later. It is a drop-in replacement for the JavaScript implementation that ships with CouchDB.

Usage

To use the CouchDB Query Server Go, you need to add couchgo executable to the CouchDB and add the following environment variable:

export COUCHDB_QUERY_SERVER_GO=/path/to/couchgo

Then you can write your design documents in Go and use them in CouchDB.

{
  "_id": "_design/example",
  "views": {
    "view-1": {
      "map": "func Map(args couchgo.MapInput) couchgo.MapOutput {\n\tout := make([][2]any, 0)\n\tout = append(out, [2]any{args.Doc[\"_id\"], args.Doc[\"type\"]})\n\n\treturn out\n}"
    },
    "view-2": {
      "map": "func Map(args couchgo.MapInput) couchgo.MapOutput {  \n    out := couchgo.MapOutput{}\n\tout = append(out, [2]interface{}{args.Doc[\"_id\"], 1})\n\tout = append(out, [2]interface{}{args.Doc[\"_id\"], 2})\n\tout = append(out, [2]interface{}{args.Doc[\"_id\"], 3})\n\t\n\treturn out\n}",
      "reduce": "func Reduce(args couchgo.ReduceInput) couchgo.ReduceOutput {\n\tout := 0.0\n\n\tfor _, value := range args.Values {\n\t\tout += value.(float64)\n\t}\n\n\treturn out\n}"
    }
  },
  "filters": {
    "filter-1": "func Filter(args couchgo.FilterInput) couchgo.FilterOutput {\n\treturn args.Doc[\"type\"] == \"post\"\n}"
  },
  "updates": {
    "update-1": "func Update(args couchgo.UpdateInput) couchgo.UpdateOutput {\n\targs.Doc[\"updated\"] = true\n\treturn couchgo.UpdateOutput{args.Doc, \"ok\"}\n}"
  },
  "rewrites": "func Rewrite(args couchgo.RewriteInput) couchgo.RewriteOutput {\n\treturn couchgo.RewriteOutput{\n\t\tHeaders: map[string]string{\"Location\": \"https://example.com\"},\n\t\tCode:    302,\n\t}\n}",
  "validate_doc_update": "func Validate(args couchgo.ValidateInput) couchgo.ValidateOutput {\n\treturn nil\n}",
  "language": "go"
}

Caveats

The Couchdb Query Server Go is a work in progress and is not yet feature complete. It implements only minimal functionality without commands that are marked as deprecated in the CouchDB documentation.

Notes

go build -o ./bin/couchgo ./lib

Benchmarks

TestCouchGO!CouchJSBoost
Indexing (100k docs)141.713s421.529s2.97x
Reducing (100k docs)7672ms15642ms2.04x
Filtering (100k docs)28.928s80.594s2.79x
Updating (1k docs)7.742s9.661s1.25x

FAQs

Package last updated on 10 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc