Beispiel #1
0
func init() {
	s, err := mgo.Dial("127.0.0.1:27017")
	if err != nil {
		panic(err)
	}
	d := s.DB("test")
	err = d.DropDatabase()
	if err != nil {
		panic(err)
	}
	session = s
	testDb = d
	db = mongoDb.New(session, testDb, map[string]interface{}{}, emptyHooks.New())
	emptyOptDoc := nesteddata.New(map[string]interface{}{})
	clientId := db.NewId()
	e = &Entries{
		shared{
			db,
			clientId,
			false,
			emptyOptDoc,
			"timeTables",
			"intervals",
			false,
		},
	}
	proId = db.NewId()
	tt = &TimeTable{
		shared{
			db,
			proId,
			true,
			emptyOptDoc,
			"timeTables",
			"intervals",
			false,
		},
	}
	newFilter := func(coll string) iface.Filter {
		f, err := db.NewFilter(coll, nil)
		if err != nil {
			panic(err)
		}
		return f
	}
	newE = func() iface.Filter {
		return newFilter("entries")
	}
	newTT = func() iface.Filter {
		return newFilter("timeTables")
	}
	newI = func() iface.Filter {
		return newFilter("intervals")
	}
}
Beispiel #2
0
func New(opts, m map[string]interface{}) *Options {
	return &Options{
		nesteddata.New(opts),
		nesteddata.New(m),
	}
}