GithubHelp home page GithubHelp logo

bson's Issues

Improve BSON tags for unnamed field

Right now the following field will get Bar BSON tag.

type Foo struct {
    Bar string
}

However, official Mongo client and mgo will generate bar. Decide which behaviour is better.

Struct cache probably doesn't work with nested structs

Currently in getStructInfo we iterate over top-level fields. Fields of fields of struct are ignored.

Also, we can sort fields once when we add a struct for the first time, so sort in structInfo.asDoc can be omitted.

Rename RawObject to RawDocument

RawObject will decode only 1st level fields of the encoded documet.

On the other side RawDocument is already an encoded document and no processing should be made.

Add logging helpers to `bsonproto`

func LogValue[T ScalarType](v T) slog.Value
func LogValueAny(v any) slog.Value

or

func GoString[T ScalarType](v T) string
func GoString(v any) string

given that the representation is always a Go-code-like string? For example, int32(42) and int64(42).

Pool temporary D objects

During encoding we've a few places where we allocate a new D for short period of time. Such allocations are harmless but we can get rid of them by allocating a D from sync.Pool.

As a result we should have zero-alloc encoding (in terms of D allocs, buffer grow or reflect is a separate topic).

Also: M.AsD() D should have an unexported version where we encode M into a given D.

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.