Created
April 28, 2016 11:07
-
-
Save sumitasok/23571320409585f4afe8d75972732638 to your computer and use it in GitHub Desktop.
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
_id, preview_token | |
permalink, preview_token | |
type publicQueryGen bson.M | |
type manageQueryGen bson.M | |
func (qG publicQueryGen) Get(config) ([]Events, error) { | |
var e []Ebvents | |
err := return db(config.DB).C(config.C).Find(qG).All(&e) | |
return e, err | |
} | |
(qG *publicQueryGen)HasID(id string) publicQueryGen { | |
// removes multiple implementation | |
if !id.IsValidBsonID(){ | |
return qG | |
} | |
qG["_id"] = bson.ObjectId(id) | |
return qG | |
} | |
(qG *publicQueryGen) HasPermalink(permalink string) publicQueryGen{ | |
if permalink.IsBsonID(){ | |
return qG | |
} | |
qG["permalink"] = permalink | |
return qG | |
} | |
(qG *manageQueryGen)HasID(id bson.ObjectId) manageQueryGen { | |
qG["_id"] = id | |
return qG | |
} | |
(qG *manageQueryGen) HasPermalink(permalink string) manageQueryGen{ | |
qG["permalink"] = permalink | |
return qG | |
} | |
(qG *manageQueryGen) WithPreviewToken(preview_token string) publicQueryGen{ | |
qG["preview_token"] = preview_token | |
return qG | |
} | |
//publicQueryGen.HasID(_id).WithPreviewToken(preview_token).Get() | |
//publicQueryGen.HasPermalink(permalink).WithPreviewToken(preview_token) | |
publicQueryGenEvent := new(publicQueryGen) | |
if its ID { | |
publicQueryGen.HasID(id) | |
} | |
publicQueryGenEvent.HasPermalink(permalink) | |
if !(previewToken != "") { | |
publicQueryGenEvent.HasPreviewToken(preview_token) | |
} | |
events, err := publicQueryGenEvent.Get(config) | |
if err != nil { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment