Skip to content
Node: mongoosegithub.com/sahilkhaire/gox/mongo

Collection

Overview

Collection wraps mongo.Collection with helper methods.

Part of the mongo package — Node.js analog: mongoose.

Collection is a type exported by gox. Methods on this type are documented separately.

Signature

go
type Collection struct {
	// contains filtered or unexported fields
}

Compare: Node.js · Standard Go · gox

js
// Typical mongoose pattern in Node.js
go
client, err := mongo.Connect(ctx, options.Client().ApplyURI(uri))
go
import "github.com/sahilkhaire/gox/mongo"

coll := db.Collection("users")

Example

go
import "github.com/sahilkhaire/gox/mongo"

coll := db.Collection("users")

Tips

Pass context.Context as the first argument so cancellation and deadlines propagate correctly.

Standard library alternative

Use the standard library directly:

go
client, err := mongo.Connect(ctx, options.Client().ApplyURI(uri))

Back to mongo package overview

MIT Licensed · Built for Node.js developers moving to Go