Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter multiple columns using sqlite.swift?

let part = self.parts.filter(self.deleteStatus == 0).order(self.id.asc)

Above is the query I run to get all the records from local database. Now I want to add more filters like id==5 or name='product' in the filter. But the filter in sqlite.swift doesn't allow more than one expression in filter. How can I add more or filters in the filter method?

like image 248
e.k Avatar asked Oct 30 '25 13:10

e.k


1 Answers

Filters can be chained with && (SQLite AND) and || (SQLite OR).

self.filter(deleteStatus == 0 && id == 5 && name == "product")

https://github.com/stephencelis/SQLite.swift/blob/master/Documentation/Index.md#filter-operators-and-functions

like image 182
btraas Avatar answered Nov 02 '25 04:11

btraas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!