MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / GetProject

Function GetProject

cmd/cql-proxy/model/project.go:63–80  ·  view source on GitHub ↗

GetProject fetches project object for specified name (database hash or project name alias).

(db *gorp.DbMap, name string)

Source from the content-addressed store, hash-verified

61
62// GetProject fetches project object for specified name (database hash or project name alias).
63func GetProject(db *gorp.DbMap, name string) (p *Project, err error) {
64 // if the alias fits to a hash, query using database id
65 var h hash.Hash
66 err = hash.Decode(&h, name)
67 if err == nil {
68 err = db.SelectOne(&p, `SELECT * FROM "project" WHERE "database_id" = ? LIMIT 1`, name)
69 }
70
71 if err == nil {
72 return
73 }
74
75 err = db.SelectOne(&p, `SELECT * FROM "project" WHERE "alias" = ? LIMIT 1`, name)
76 if err != nil {
77 err = errors.Wrapf(err, "get project failed")
78 }
79 return
80}
81
82// GetProjectByID fetches the project object using project database id.
83func GetProjectByID(db *gorp.DbMap, dbID proto.DatabaseID, developer int64) (p *Project, err error) {

Callers 1

projectIDInjectFunction · 0.92

Calls 1

DecodeFunction · 0.92

Tested by

no test coverage detected