forked from andeya/pholcus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
155 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,40 @@ | ||
package mgo | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// 传入数据库列表 | 返回数据库及其集合树 | ||
type List struct { | ||
Dbs []string //数据库名称列表 | ||
// Result struct { | ||
// Tree map[string][]string | ||
// } | ||
} | ||
|
||
func (self *List) Exec() (interface{}, error) { | ||
func (self *List) Exec(resultPtr interface{}) (err error) { | ||
defer func() { | ||
if re := recover(); re != nil { | ||
err = fmt.Errorf("%v", re) | ||
} | ||
}() | ||
resultPtr2 := resultPtr.(*map[string][]string) | ||
*resultPtr2 = map[string][]string{} | ||
|
||
s := MgoPool.GetOne().(*MgoSrc) | ||
defer MgoPool.Free(s) | ||
var err error | ||
|
||
var dbs []string | ||
if dbs, err = s.DatabaseNames(); err != nil { | ||
return nil, err | ||
return err | ||
} | ||
|
||
var result = make(map[string][]string) | ||
|
||
if len(self.Dbs) == 0 { | ||
for _, dbname := range dbs { | ||
result[dbname], _ = s.DB(dbname).CollectionNames() | ||
(*resultPtr2)[dbname], _ = s.DB(dbname).CollectionNames() | ||
} | ||
return result, err | ||
return err | ||
} | ||
|
||
for _, dbname := range self.Dbs { | ||
result[dbname], _ = s.DB(dbname).CollectionNames() | ||
(*resultPtr2)[dbname], _ = s.DB(dbname).CollectionNames() | ||
} | ||
return result, err | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.