Giter Site home page Giter Site logo

gocb-example's Introduction

Some code to demonstrate the following GoCB usage:

  • Copies the data from a source bucket to a target bucket
    • Iterate docs via N1QL query
    • Iterate docs via View query
  • Anonymizes the document contents via json-anonymizer
  • Add an XATTR (Extended Attribute) to each doc
  • Manipulate fields via Subdoc API

Setup

go get github.com/couchbaselabs/gocb-example
  • Install Couchbase 5.X beta 2
  • Create travel sample data bucket via Couchbase UI
  • Create a new empty bucket called travel-sample-copy
  • Create RBAC users
    • username: travel-sample password: "password"
    • username: travel-sample-copy password: "password"
  • In the main() function, you can toggle the UseN1QL flag to have it use N1QL vs Views to walk the source bucket

References

gocb-example's People

Contributors

tleyden avatar

Watchers

Steve Yen avatar Thuan Nguyen avatar Sarath Lakshman avatar  avatar  avatar Mike Wiederhold avatar Jeffry Morris avatar Pasin Suriyentrakorn avatar Abhishek Singh avatar James Cloos avatar Dean Proctor avatar Dipti Borkar avatar Alex Ma avatar Brett Lawson avatar  avatar Wayne Siu avatar Sundar Sridharan avatar  avatar  avatar Sriram Ganesan avatar Dan Owen avatar Manu Dhundi avatar Andrew Reslan avatar Dave Finlay avatar  avatar  avatar vickiezeng avatar Couchbase Robot avatar  avatar Adam Fraser avatar  avatar Keshav Murthy avatar Laura Czajkowski avatar  avatar

gocb-example's Issues

issues identified by gometalinter

Some of these are subjective, but if this is being used as our example going forward I'd suggest we try to resolve most of these:

main.go:594::error: unreachable code (vet)
main.go:274::warning: SQL string formatting,MEDIUM,HIGH (gas)
main.go:24:2:warning: const sampleDocId should be sampleDocID (golint)
main.go:38:6:warning: exported type DocProcessorInput should have comment or be unexported (golint)
main.go:43:1:warning: comment on exported type DocProcessor should be of the form "DocProcessor ..." (with optional leading article) (golint)
main.go:46:6:warning: exported type DocProcessorReturnDocs should have comment or be unexported (golint)
main.go:48:6:warning: exported type BucketSpec should have comment or be unexported (golint)
main.go:54:1:warning: comment on exported type ExampleApp should be of the form "ExampleApp ..." (with optional leading article) (golint)
main.go:67:1:warning: comment on exported function NewExample should be of the form "NewExample ..." (golint)
main.go:156:1:warning: exported method ExampleApp.CopyBucketAnonymizeDoc should have comment or be unexported (golint)
main.go:178:10:warning: range var docId should be docID (golint)
main.go:186:4:warning: var newDocId should be newDocID (golint)
main.go:189:5:warning: var anonymizedDocId should be anonymizedDocID (golint)
main.go:215:1:warning: comment on exported method ExampleApp.CopyBucketAddXATTRS should be of the form "CopyBucketAddXATTRS ..." (golint)
main.go:223:10:warning: range var docId should be docID (golint)
main.go:262:1:warning: exported method ExampleApp.CopyBucket should have comment or be unexported (golint)
main.go:270:1:warning: exported function TableScanN1qlQuery should have comment or be unexported (golint)
main.go:281:1:warning: exported method ExampleApp.CopyBucketWithCallback should have comment or be unexported (golint)
main.go:319:11:warning: range var docId should be docID (golint)
main.go:358:1:warning: exported method ExampleApp.GetXattrs should have comment or be unexported (golint)
main.go:358:32:warning: method parameter docId should be docID (golint)
main.go:373:1:warning: exported method ExampleApp.GetSubdocField should have comment or be unexported (golint)
main.go:373:37:warning: method parameter docId should be docID (golint)
main.go:385:1:warning: exported method ExampleApp.SetSubdocField should have comment or be unexported (golint)
main.go:385:37:warning: method parameter docId should be docID (golint)
main.go:399:1:warning: comment on exported method ExampleApp.ForEachDocIdTargetBucket should be of the form "ForEachDocIdTargetBucket ..." (golint)
main.go:400:22:warning: method ForEachDocIdTargetBucket should be ForEachDocIDTargetBucket (golint)
main.go:403:9:warning: if block ends with a return statement, so drop this else and outdent its block (golint)
main.go:408:1:warning: exported method ExampleApp.ForEachDocIdSourceBucket should have comment or be unexported (golint)
main.go:408:22:warning: method ForEachDocIdSourceBucket should be ForEachDocIDSourceBucket (golint)
main.go:411:9:warning: if block ends with a return statement, so drop this else and outdent its block (golint)
main.go:416:1:warning: comment on exported method ExampleApp.ForEachDocIdBucketN1ql should be of the form "ForEachDocIdBucketN1ql ..." (golint)
main.go:417:22:warning: method ForEachDocIdBucketN1ql should be ForEachDocIDBucketN1ql (golint)
main.go:433:3:warning: var rowIdRaw should be rowIDRaw (golint)
main.go:437:3:warning: var rowIdStr should be rowIDStr (golint)
main.go:460:1:warning: exported method ExampleApp.ForEachDocIdBucketViewsConcurrent should have comment or be unexported (golint)
main.go:460:22:warning: method ForEachDocIdBucketViewsConcurrent should be ForEachDocIDBucketViewsConcurrent (golint)
main.go:521:1:warning: comment on exported method ExampleApp.ForEachDocIdBucketViews should be of the form "ForEachDocIdBucketViews ..." (golint)
main.go:523:22:warning: method ForEachDocIdBucketViews should be ForEachDocIDBucketViews (golint)
main.go:564:4:warning: var rowIdRaw should be rowIDRaw (golint)
main.go:568:4:warning: var rowIdStr should be rowIDStr (golint)
main.go:582:4:warning: should replace skip += 1 with skip++ (golint)
main.go:583:4:warning: should replace numResultsProcessed += 1 with numResultsProcessed++ (golint)
main.go:599:1:warning: exported method ExampleApp.AddNameSpaceToTypeFieldViaSubdoc should have comment or be unexported (golint)
main.go:605:10:warning: range var docId should be docID (golint)
main.go:672::warning: declaration of "err" shadows declaration at main.go:655 (vetshadow)
main.go:239:80:warning: unnecessary conversion (unconvert)
main.go:281::warning: cyclomatic complexity 11 of function (*ExampleApp).CopyBucketWithCallback() is high (> 10) (gocyclo)
main.go:207:2:warning: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (gosimple)
main.go:254:2:warning: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (gosimple)
main.go:263:2:warning: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (gosimple)
main.go:391:2:warning: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (gosimple)
main.go:553:41:warning: should omit comparison to bool constant, can be simplified to !gotRow (S1002) (gosimple)
main.go:624:2:warning: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013) (gosimple)
main.go:367:13:warning: error return value not checked (res.Content(xattrKey, &xattrVal)) (errcheck)
main.go:379:14:warning: error return value not checked (frag.Content(subdocKey, &retValue)) (errcheck)
main.go:644:11:warning: error return value not checked (e.Connect("couchbase://localhost")) (errcheck)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.