4
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?

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

Comments

-2

The filter in Sqlite.swift does allow more than one expression; you just chain them together like this:

users.filter(id == 1 %% location == "Office" %% supervisor == "John")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.