本文整理匯總了Golang中github.com/eaciit/dbox.Or函數的典型用法代碼示例。如果您正苦於以下問題:Golang Or函數的具體用法?Golang Or怎麽用?Golang Or使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Or函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: FindDataGrabber
func (d *DataGrabberController) FindDataGrabber(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
//~ payload := map[string]string{"inputText":"test"}
payload := map[string]interface{}{}
err := r.GetPayload(&payload)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
text := payload["inputText"].(string)
textLow := strings.ToLower(text)
var query *dbox.Filter
valueInt, errv := strconv.Atoi(text)
fmt.Printf("", valueInt)
fmt.Printf("", errv)
if errv == nil {
// == try useing Eq for support integer
query = dbox.Or(dbox.Eq("GrabInterval", valueInt), dbox.Eq("TimeoutInterval", valueInt))
} else {
// == try useing Contains for support autocomplite
query = dbox.Or(dbox.Contains("_id", text), dbox.Contains("_id", textLow), dbox.Contains("DataSourceOrigin", text), dbox.Contains("DataSourceOrigin", textLow), dbox.Contains("DataSourceDestination", text), dbox.Contains("DataSourceDestination", textLow), dbox.Contains("IntervalType", text), dbox.Contains("IntervalType", textLow))
}
data := []colonycore.DataGrabber{}
cursor, err := colonycore.Find(new(colonycore.DataGrabber), query)
cursor.Fetch(&data, 0, false)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
defer cursor.Close()
return helper.CreateResult(true, data, "")
}
示例2: GetListData
func (a *DataFlowController) GetListData(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := map[string]interface{}{}
err := r.GetPayload(&payload)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
search := tk.ToString(payload["search"])
var query *dbox.Filter
if search != "" {
query = dbox.Or(dbox.Contains("name", search), dbox.Contains("description", search), dbox.Contains("createdby", search))
}
cursor, err := colonycore.Find(new(colonycore.DataFlow), query)
dataDs := []colonycore.DataFlow{}
if cursor != nil {
cursor.Fetch(&dataDs, 0, false)
defer cursor.Close()
}
if err != nil && cursor != nil {
return helper.CreateResult(false, nil, err.Error())
}
return helper.CreateResult(true, dataDs, "success")
}
示例3: FindConnection
func (d *DataSourceController) FindConnection(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
//~ payload := map[string]string{"inputText":"tes","inputDrop":""}
payload := map[string]interface{}{}
err := r.GetPayload(&payload)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
text := payload["inputText"].(string)
pilih := payload["inputDrop"].(string)
textLow := strings.ToLower(text)
// == try useing Contains for support autocomplite
var query *dbox.Filter
if text != "" {
query = dbox.Or(dbox.Contains("_id", text), dbox.Contains("_id", textLow), dbox.Contains("Database", text), dbox.Contains("Database", textLow), dbox.Contains("Driver", text), dbox.Contains("Driver", textLow), dbox.Contains("Host", text), dbox.Contains("Host", textLow), dbox.Contains("UserName", text), dbox.Contains("UserName", textLow), dbox.Contains("Password", text), dbox.Contains("Password", textLow))
}
if pilih != "" {
query = dbox.And(query, dbox.Eq("Driver", pilih))
}
data := []colonycore.Connection{}
cursor, err := colonycore.Find(new(colonycore.Connection), query)
cursor.Fetch(&data, 0, false)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
defer cursor.Close()
return helper.CreateResult(true, data, "")
}
示例4: RemoveDataSource
func (d *DataSourceController) RemoveDataSource(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := map[string]interface{}{}
err := r.GetPayload(&payload)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
id := payload["_id"].(string)
dg := new(colonycore.DataGrabber)
filter := dbox.Or(dbox.Eq("DataSourceOrigin", id), dbox.Eq("DataSourceDestination", id))
cursor, err := colonycore.Find(dg, filter)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
defer cursor.Close()
if cursor.Count() > 0 {
return helper.CreateResult(false, nil, "Cannot delete data source because used on data grabber")
}
o := new(colonycore.DataSource)
o.ID = id
err = colonycore.Delete(o)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
return helper.CreateResult(true, nil, "")
}
示例5: GetDataSources
func (d *DataSourceController) GetDataSources(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := map[string]interface{}{}
err := r.GetPayload(&payload)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
search := payload["search"].(string)
var query *dbox.Filter
query = dbox.Or(dbox.Contains("_id", search), dbox.Contains("ConnectionID", search))
cursor, err := colonycore.Find(new(colonycore.DataSource), query)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
data := []colonycore.DataSource{}
err = cursor.Fetch(&data, 0, false)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
defer cursor.Close()
return helper.CreateResult(true, data, "")
}
示例6: TestSelectFilter
func TestSelectFilter(t *testing.T) {
t.Skip()
c, e := prepareConnection()
if e != nil {
t.Errorf("Unable to connect %s \n", e.Error())
return
}
defer c.Close()
csr, e := c.NewQuery().
Select("empno", "ename", "mgr", "hiredate").
Where(dbox.Or(dbox.Eq("empno", 7521), dbox.Eq("ename", "ADAMS"))).
From(tableName).Cursor(nil)
if e != nil {
t.Errorf("Cursor pre error: %s \n", e.Error())
return
}
if csr == nil {
t.Errorf("Cursor not initialized")
return
}
defer csr.Close()
rets := /*[]customers{}*/ []toolkit.M{}
e = csr.Fetch(&rets, 0, false)
if e != nil {
t.Errorf("Unable to fetch: %s \n", e.Error())
} else {
toolkit.Printf("Filter OK. Result: %v \n", toolkit.JsonString(rets))
}
}
示例7: UninstallLang
func (l *LangenvironmentController) UninstallLang(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := new(colonycore.LanguageEnvironmentPayload)
err := r.GetPayload(payload)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
dataServers := new(colonycore.Server)
err = colonycore.Get(dataServers, payload.ServerId)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
serverPathSeparator := CreateApplicationController(l.Server).GetServerPathSeparator(dataServers)
sshSetting, sshClient, err := dataServers.Connect()
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
defer sshClient.Close()
var query *dbox.Filter
if payload.Lang == LANG_SCALA {
var IsInstalled bool
for _, eachLang := range dataServers.InstalledLang {
if eachLang.Lang == LANG_JAVA {
IsInstalled = eachLang.IsInstalled
break
}
}
if !IsInstalled {
query = dbox.Or(dbox.Eq("language", LANG_JAVA), dbox.Eq("language", LANG_SCALA))
} else {
query = dbox.Eq("language", payload.Lang)
}
} else {
query = dbox.Eq("language", payload.Lang)
}
result, err := l.ProcessSetup(dataServers, query, serverPathSeparator, sshSetting)
if err != nil {
helper.CreateResult(false, nil, err.Error())
}
fmt.Println("result :: ", result)
for _, eachLang := range dataServers.InstalledLang {
if eachLang.Lang == payload.Lang {
eachLang.IsInstalled = false
break
}
}
err = colonycore.Save(dataServers)
if err != nil {
helper.CreateResult(false, nil, err.Error())
}
return helper.CreateResult(true, payload, "")
}
示例8: FindWebGrabber
func (d *WebGrabberController) FindWebGrabber(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
//~ payload := map[string]string{"inputText": "GRAB_TEST", "inputRequest": "", "inputType": ""}
payload := map[string]interface{}{}
err := r.GetPayload(&payload)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
text := payload["inputText"].(string)
req := payload["inputRequest"].(string)
tipe := payload["inputType"].(string)
textLow := strings.ToLower(text)
// == bug, cant find if autocomplite, just full text can be get result
var query *dbox.Filter
if text != "" {
valueInt, errv := strconv.Atoi(text)
if errv == nil {
// == try useing Eq for support integer
query = dbox.Or(dbox.Eq("GrabInterval", valueInt), dbox.Eq("TimeoutInterval", valueInt))
} else {
// == try useing Contains for support autocomplite
query = dbox.Or(dbox.Contains("_id", text), dbox.Contains("_id", textLow), dbox.Contains("Calltype", text), dbox.Contains("Calltype", textLow), dbox.Contains("SourceType", text), dbox.Contains("SourceType", textLow), dbox.Contains("IntervalType", text), dbox.Contains("IntervalType", textLow))
}
}
if req != "" {
query = dbox.And(query, dbox.Eq("Calltype", req))
}
if tipe != "" {
query = dbox.And(query, dbox.Eq("SourceType", tipe))
}
data := []colonycore.WebGrabber{}
cursor, err := colonycore.Find(new(colonycore.WebGrabber), query)
cursor.Fetch(&data, 0, false)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
defer cursor.Close()
return helper.CreateResult(true, payload, "")
}
示例9: TestDelete
func TestDelete(t *testing.T) {
t.Skip("Skip : Comment this line to do test")
skipIfConnectionIsNil(t)
e := ctx.NewQuery().Delete().From("Data_CUD").SetConfig("multiexec", true).Where(dbox.Or(dbox.Eq("Id", "ID-11"), dbox.Eq("Id", "ID-13"))).Exec(nil)
if e != nil {
t.Fatalf("Delete fail: %s", e.Error())
}
}
示例10: TestFilter
func TestFilter(t *testing.T) {
fb := dbox.NewFilterBuilder(new(FilterBuilder))
fb.AddFilter(dbox.Or(
dbox.Eq("_id", 1),
dbox.Eq("group", "administrators")))
b, e := fb.Build()
if e != nil {
t.Errorf("Error %s", e.Error())
} else {
fmt.Printf("Result:\n%v\n", toolkit.JsonString(b))
}
}
示例11: GetServers
func (s *ServerController) GetServers(r *knot.WebContext) interface{} {
r.Config.OutputType = knot.OutputJson
payload := struct {
Search string `json:"search"`
ServerOS string `json:"serverOS"`
ServerType string `json:"serverType"`
SSHType string `json:"sshType"`
}{}
err := r.GetPayload(&payload)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
filters := []*dbox.Filter{}
if payload.Search != "" {
filters = append(filters, dbox.Or(
dbox.Contains("_id", payload.Search),
dbox.Contains("os", payload.Search),
dbox.Contains("host", payload.Search),
dbox.Contains("serverType", payload.Search),
dbox.Contains("sshtype", payload.Search),
))
}
if payload.ServerOS != "" {
filters = append(filters, dbox.Eq("os", payload.ServerOS))
}
if payload.ServerType != "" {
filters = append(filters, dbox.Eq("serverType", payload.ServerType))
}
if payload.SSHType != "" {
filters = append(filters, dbox.Eq("sshtype", payload.SSHType))
}
var query *dbox.Filter
if len(filters) > 0 {
query = dbox.And(filters...)
}
cursor, err := colonycore.Find(new(colonycore.Server), query)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
data := []colonycore.Server{}
err = cursor.Fetch(&data, 0, false)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
defer cursor.Close()
return helper.CreateResult(true, data, "")
}
示例12: TestFilter
func TestFilter(t *testing.T) {
fb := dbox.NewFilterBuilder(new(FilterBuilder))
fb.AddFilter(dbox.Or(
dbox.Contains("regfield", "1"),
dbox.Ne("nefield", 1),
dbox.Eq("group", "administrators")))
b, e := fb.Build()
if e != nil {
t.Errorf("Error %s", e.Error())
} else {
fmt.Printf("Result:\n%v\n", toolkit.JsonString(b))
}
fb = dbox.NewFilterBuilder(new(FilterBuilder))
fb.AddFilter(dbox.And(dbox.Or(dbox.Eq("EmployeeId", "101-102-10"), dbox.Eq("EmployeeId", "101-102-3"), dbox.Eq("EmployeeId", "101-102-4")), dbox.Eq("Age", "30")))
c, e := fb.Build()
if e != nil {
t.Errorf("Error %s", e.Error())
} else {
fmt.Printf("Result:\n%v\n", toolkit.JsonString(c))
}
}
示例13: filterCondition
func filterCondition(cond toolkit.M) *dbox.Filter {
fb := new(dbox.Filter)
for key, val := range cond {
if key == "$and" || key == "$or" {
afb := []*dbox.Filter{}
for _, sVal := range val.([]interface{}) {
rVal := sVal.(map[string]interface{})
mVal := toolkit.M{}
for rKey, mapVal := range rVal {
mVal.Set(rKey, mapVal)
}
afb = append(afb, filterCondition(mVal))
}
if key == "$and" {
fb = dbox.And(afb...)
} else {
fb = dbox.Or(afb...)
}
} else {
if reflect.ValueOf(val).Kind() == reflect.Map {
mVal := val.(map[string]interface{})
tomVal, _ := toolkit.ToM(mVal)
switch {
case tomVal.Has("$eq"):
fb = dbox.Eq(key, tomVal["$eq"].(string))
case tomVal.Has("$ne"):
fb = dbox.Ne(key, tomVal["$ne"].(string))
case tomVal.Has("$regex"):
fb = dbox.Contains(key, tomVal["$regex"].(string))
case tomVal.Has("$gt"):
fb = dbox.Gt(key, tomVal["$gt"].(string))
case tomVal.Has("$gte"):
fb = dbox.Gte(key, tomVal["$gte"].(string))
case tomVal.Has("$lt"):
fb = dbox.Lt(key, tomVal["$lt"].(string))
case tomVal.Has("$lte"):
fb = dbox.Lte(key, tomVal["$lte"].(string))
}
} else {
fb = dbox.Eq(key, val)
}
}
}
return fb
}
示例14: GetAccess
func (a *AdministrationController) GetAccess(r *knot.WebContext) interface{} {
var filter *dbox.Filter
r.Config.OutputType = knot.OutputJson
a.InitialSetDatabase()
payload := map[string]interface{}{}
err := r.GetForms(&payload)
if strings.Contains(toolkit.TypeName(payload["find"]), "float") {
payload["find"] = toolkit.ToInt(payload["find"], toolkit.RoundingAuto)
}
tAccess := new(acl.Access)
if find := toolkit.ToString(payload["find"]); find != "" {
filter = new(dbox.Filter)
filter = dbox.Or(dbox.Contains("id", find),
dbox.Contains("title", find),
dbox.Contains("group1", find),
dbox.Contains("group2", find),
dbox.Contains("group3", find),
dbox.Contains("specialaccess1", find),
dbox.Contains("specialaccess2", find),
dbox.Contains("specialaccess3", find),
dbox.Contains("specialaccess4", find))
}
data := toolkit.M{}
arrm := make([]toolkit.M, 0, 0)
take := toolkit.ToInt(payload["take"], toolkit.RoundingAuto)
skip := toolkit.ToInt(payload["skip"], toolkit.RoundingAuto)
c, err := acl.Find(tAccess, filter, toolkit.M{}.Set("take", take).Set("skip", skip))
if err == nil {
err = c.Fetch(&arrm, 0, false)
}
c.Close()
c, err = acl.Find(tAccess, filter, nil)
data.Set("Datas", arrm)
data.Set("total", c.Count())
if err != nil {
return helper.CreateResult(true, nil, err.Error())
} else {
return helper.CreateResult(true, data, "")
}
}
示例15: GetUser
func (a *UserController) GetUser(r *knot.WebContext) interface{} {
var filter *dbox.Filter
r.Config.OutputType = knot.OutputJson
_ = a.InitialSetDatabase()
payload := map[string]interface{}{}
err := r.GetForms(&payload)
if err != nil {
return helper.CreateResult(false, nil, err.Error())
}
if strings.Contains(toolkit.TypeName(payload["find"]), "float") {
payload["find"] = toolkit.ToInt(payload["find"], toolkit.RoundingAuto)
}
tUser := new(acl.User)
if find := toolkit.ToString(payload["find"]); find != "" {
filter = new(dbox.Filter)
filter = dbox.Or(dbox.Contains("id", find),
dbox.Contains("fullname", find),
dbox.Contains("email", find))
}
take := toolkit.ToInt(payload["take"], toolkit.RoundingAuto)
skip := toolkit.ToInt(payload["skip"], toolkit.RoundingAuto)
c, err := acl.Find(tUser, filter, toolkit.M{}.Set("take", take).Set("skip", skip))
if err != nil {
return helper.CreateResult(true, nil, err.Error())
}
data := toolkit.M{}
arrm := make([]toolkit.M, 0, 0)
err = c.Fetch(&arrm, 0, false)
c.Close()
c, err = acl.Find(tUser, filter, nil)
data.Set("Datas", arrm)
data.Set("total", c.Count())
if err != nil {
return helper.CreateResult(true, nil, err.Error())
} else {
return helper.CreateResult(true, data, "")
}
}