Skip to content

Support for Multiple Where clauses? #4

Description

@c2technology

given

type Person struct {
  PersonID string  `json:"person_id"`
  First string  `json:"first"`
  Middle string  `json:"middle"`
  Last string  `json:"last"`
}
func (p Person) String() string {
	return fmt.Sprintf("%s %s %s %s", p.PersonID, p.First, p.Middle, p.Last)
}

func (p Person) ID() (jsonField string, value interface{}) {
	value=p.PersonID
	jsonField="personID"
	return
}

And I add records:

driver, err := simdb.New("D:\\_MUSIC\\person")
if err != nil {
	panic(err)
}
person1 := Person{
	PersonID: "1",
	First: "John",
	Middle: "Q",
	Last: "Smith",
}

person2 := Person{
	PersonID: "2",
	First: "Suzy",
	Middle: "Q",
	Last: "Smith",
}
driver.Insert(person1)
driver.Insert(person2)

When querying a single element, I get the expected results:

people := []Person{}
driver.Open(Person{}).Where("last","eq","Smith").Get().AsEntity(&people)
fmt.Println(people)

Output: [1 John Q Smith 2 Suzy Q Smith]
But when I combine queries, I get empty results:

people = []Person{}
driver.Open(Person{}).Where("last","==","Smith").Where("first","==","Suzy").Get().AsEntity(&people)
fmt.Println(people)

Output: []

I'm expecting: [1 John Q Smith 2 Suzy Q Smith]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions