Ecosyste.ms: Packages

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

Top 8.2% on proxy.golang.org

proxy.golang.org : gopkg.in/zebresel-com/mongodm.v1

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.

Registry - Source - Documentation - JSON
purl: pkg:golang/gopkg.in/zebresel-com/mongodm.v1
Keywords: document-mapper, golang, golang-library, mapper, mongodb, odm
License: GPL-2.0
Latest release: over 6 years ago
First release: over 7 years ago
Namespace: gopkg.in/zebresel-com
Stars: 195 on GitHub
Forks: 33 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 24 days ago

    Loading...
    Readme
    Loading...