mongo-gen

command module
v0.0.0-...-ec57482 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

README

mongo-gen

mongo-gen is a Go library for generating Mongo models for Go programs.

In your project, provide a orm.yml file with the following information:

  • The input package's name and path containing your input structs.
  • The output package name and path to output the structs and its relevant methods.
  • Run go run github.com/jonoans/mongo-gen generate

mongo-gen attempts to generate working (hopefully) methods to resolve references to other collections.

Check out orm.yml for an example configuration and the examples directory for the input models and generated code.

Input Models

Provide your input models as structs in the package indicated in the orm.yml file.

  • Only structs which have the codegen.BaseModel field embedded are recognised as collection documents.

Output Models

The output models will contain additional methods to hopefully make life easier.

  • GetResolved_[FIELD NAME] method for automatically resolving references.
  • Queried, Creating, Created, Saving, Saved, Updating, Updated, Deleting, Deleted hook methods.

codegen_.go

Included in the generated files, contains functions for using models.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL