Closed bodokaiser closed 10 years ago
Needs to be done before we can merge #34 also needs planning.
Problem: How to separate concrete types (e.g. Order
, Product
, Customer
) from abstract types (e.g. Store
, Query
)?
Solution: Put them together for now.
Problem: How create connection?
Solution: Just use bare mgo.Session
.
Possible structure of Store
:
type Store struct {
session *mgo.Session
database *mgo.Database
}
func (s *Store) Find(model interface{}) error {
}
func (s *Store) FindOne(model interface{}) error {
}
func (s *Store) Create(model interface{}) error {
}
func (s *Store) Update(model interface{}) error {
}
func (s *Store) Remove(model interface{}) error {
}
func (s *Store) files(model interface{}) *mgo.GridFS {
}
func (s *Store) collection(model interface{}) *mgo.Collection {
}
Though I tend to always have a
mongo
package it is actually not good as it always leads to rewriting a third classmgo
interface.As this is nothing urgent I will leave the
mongo
package outside but when there are more features to handle and themongo.Store
interface is limiting again I will merge that stuff intostore.store
.