Giter Site home page Giter Site logo

OrWhere使用not in时报错 about gorose HOT 4 CLOSED

gohouse avatar gohouse commented on May 22, 2024
OrWhere使用not in时报错

from gorose.

Comments (4)

AnsonCode avatar AnsonCode commented on May 22, 2024

不好意思,不知道怎么格式化代码。

from gorose.

fizzday avatar fizzday commented on May 22, 2024

这样的吧, markdown语法, 你可以看下代码块的用法就可以了, 非常简单, 就每行3个反引号, 在两行反引号之间写代码就可以了

func (this *DemoModel) List() (int, []map[string]interface{}, error) {
	userM := this.GetTable()
	count, err := userM.Count("*")
	result, err := userM.OrWhere("name", "not in", []string{"小米"}).Get()
	//这里报错 
	lastsql := db.LastSql()
	log.Debug(lastsql)
	if (err != nil) {
		return 0, result, err
	}
	this.UseGetter(result)
	return count, result, nil
}

from gorose.

fizzday avatar fizzday commented on May 22, 2024

@caoyanbin1993
OrWhere() 用法

OrWhere("id", "not in", []interface{}{"3"})

这里的第三个参数要用 interface 切片数组, 为了兼容 字符串, 数字等情况

另外, Get() 的返回是 []map[string]interface {}, 所以, 你用她的数据的时候, 在遇到 interface{} 时, 需要指定他的类型

from gorose.

AnsonCode avatar AnsonCode commented on May 22, 2024

通过修改collection.Colunm的返回类型,避免了上述错误,谢谢飞哥。

from gorose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.