#386·squirrel

How to use squirrel.Not to support "Nor", I encountered an unrecognized error here

Author: wenbo1989Created Jan 12, 2025Updated Jan 13, 2025

I encountered an unrecognized error, my squirrel version is v1.5.4 , seems that there is no "Not" method in "expr.go" file.

I have a Mongo query statement such as below and I hope to convert it into MySQL.

 {
    "$nor": [
        { "age":20 },
        { "owner1": "a"}
      ]
}

so I write as below

builder := squirrel.Select("*").From("table_name")
ageCondition := squirrel.Eq{"age": 20}
owner1Condition := squirrel.Eq{"owner1": "a"}

andCondition := squirrel.And{
    ageCondition,
    owner1Condition
}
 builder = builder.Where(squirrel.Not(andCondition))  

// I encountered an unrecognized error here,and my squirrel version is v1.5.4 , seems that there is no "Not" method in "expr.go" file. query, args, err := builder.ToSql()