All Projects → chidiwilliams → flatbson

chidiwilliams / flatbson

Licence: MIT license
Recursively flatten a Go struct using its BSON tags

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to flatbson

Avocado
Strongly-typed MongoDB driver for Rust
Stars: ✭ 70 (+29.63%)
Mutual labels:  mongo, bson
Lungo
A MongoDB compatible embeddable database and toolkit for Go.
Stars: ✭ 343 (+535.19%)
Mutual labels:  mongo, bson
uuid-mongodb
📇 Generates and parses MongoDB BSON UUIDs
Stars: ✭ 94 (+74.07%)
Mutual labels:  mongo, bson
Lua Mongo
MongoDB Driver for Lua
Stars: ✭ 81 (+50%)
Mutual labels:  mongo, bson
BroadcastBot
A simple Telegram bot that can broadcast messages and media to the bot subscribers. with mongo DB support
Stars: ✭ 73 (+35.19%)
Mutual labels:  mongo
Flipper
🐬 Beautiful, performant feature flags for Ruby.
Stars: ✭ 2,732 (+4959.26%)
Mutual labels:  mongo
Chartbrew
Open-source web platform for creating charts out of different data sources (databases and APIs) 📈📊
Stars: ✭ 199 (+268.52%)
Mutual labels:  mongo
Mevn Stack
A Quickstart for building an Express API with a VueJS Admin Portal
Stars: ✭ 178 (+229.63%)
Mutual labels:  mongo
mongo-rust-driver
Mongo Rust driver built on top of the Mongo C driver
Stars: ✭ 89 (+64.81%)
Mutual labels:  mongo
gitbot
The most popular Discord dev toolkit with 400k+ users 🚀✨
Stars: ✭ 59 (+9.26%)
Mutual labels:  mongo
leveldb-cli
CLI for LevelDB
Stars: ✭ 86 (+59.26%)
Mutual labels:  bson
Php Mongo
MongoDB ODM. Part of @PHPMongoKit
Stars: ✭ 228 (+322.22%)
Mutual labels:  mongo
weightless-orm
🛸 A lightweight database mapping library
Stars: ✭ 24 (-55.56%)
Mutual labels:  mongo
Mern Passport
A boilerplate example of using passport.js for authenticating a MERN application
Stars: ✭ 214 (+296.3%)
Mutual labels:  mongo
polymorphia
A very fast POJO codec for MongoDB (used in conjunction with the Mongo Java Driver) that handles generic types as well as polymorphic class hierarchies
Stars: ✭ 21 (-61.11%)
Mutual labels:  mongo
Aspnetcore.identity.mongo
This is a MongoDB provider for the ASP.NET Core 2 Identity framework
Stars: ✭ 179 (+231.48%)
Mutual labels:  mongo
nestjs-api-mongoose
Collection example apps with NestJS and Typeorm, Sequelize, Mongodb, PostgreSQL, MySQL, GraphQL, Mercurius, etc. for the NestJS community 😻
Stars: ✭ 153 (+183.33%)
Mutual labels:  mongo
magnet
A JSON/BSON schema generator
Stars: ✭ 16 (-70.37%)
Mutual labels:  bson
MongoDB-University
Repo for All MongoDB University Courses
Stars: ✭ 102 (+88.89%)
Mutual labels:  mongo
docker-mongo
MongoDB Docker image embedding RocksDB storage engine
Stars: ✭ 32 (-40.74%)
Mutual labels:  mongo

FlatBSON

Build status API reference codecov

FlatBSON recursively flattens a Go struct using its BSON tags.

It is particularly useful for partially updating embedded Mongo documents.

For example, to update a User's Address.Visited field, first call flatbson.Flatten with the parent struct:

type User struct {
  ID      bson.ObjectID `bson:"_id,omitempty"`
  Name    string        `bson:"name,omitempty"`
  Address Address       `bson:"address,omitempty"`
}

type Address struct {
  Street    string    `bson:"street,omitempty"`
  City      string    `bson:"city,omitempty"`
  State     string    `bson:"state,omitempty"`
  VisitedAt time.Time `bson:"visitedAt,omitempty"`
}

flatbson.Flatten(User{Address: {VisitedAt: time.Now().UTC()}})

// Result:
// map[string]interface{}{"address.visitedAt": time.Time{...}}

Passing the result to coll.UpdateOne updates only the address.VisitedAt field instead of overwriting the entire address embedded document. See this blog post for more information.

The complete documentation is available on Godoc.

How to Install

go get -v github.com/chidiwilliams/flatbson
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].