An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

github.com/ewhal/mongodm

This package is an object document mapper for mongodb which uses the mgo adapter. First step is to create a model, for example: It is important that each schema embeds the IDocumentBase type (mongodm.DocumentBase) and make sure that it is tagged as 'inline' for json and bson. This base type also includes the default values id, createdAt, updatedAt and deleted. Those values are set automatically from the ODM. The given example also uses a relation (User has Messages). Relations must always be from type interface{} for storing bson.ObjectId OR a completely populated object. And of course we also need the related model for each stored message: Note that when you are using relations, each model will be stored in his own collection. So the values are not embedded and instead stored as object ID or array of object ID's. To configure a relation the ODM understands three more tags: But it is not necessary to always create relations - you also can use embedded types: Persisting a customer instance to the database would result in embedding an complete address object. You can embed all supported types. Now that you got some models it is important to create a connection to the database and to register these models for the ODM.

Ecosystem
proxy.golang.org
Latest Release
v2.0.1+incompatible
about 8 years ago
Versions
8
Links
Registry proxy.golang.org
Source Repository
Docs Documentation
JSON API View JSON
CodeMeta codemeta.json
Package Details
PURL pkg:golang/github.com/ewhal/mongodm
spec
License GPL-2.0
Namespace github.com/ewhal
First Release about 10 years ago
Last Synced 12 days ago
Repository
Stars 0 on GitHub
Forks 0 on GitHub
Rankings on proxy.golang.org
Overall Top 8.2%