Skip to content

Instantly share code, notes, and snippets.

@PhilippeBoisney
Created March 1, 2017 08:19
Show Gist options
  • Save PhilippeBoisney/70ac4024815268f7cd0d586ad8607df7 to your computer and use it in GitHub Desktop.
Save PhilippeBoisney/70ac4024815268f7cd0d586ad8607df7 to your computer and use it in GitHub Desktop.
func getAllStates(_ email: String, todayDate: Int) -> Array<ListeDeCourseStateModel> {
let realm = try! Realm()
let predicate = NSPredicate(format: "parentID = '"+email+"' AND idDayRef >= "+todayDate.description)
return realm.objects(ListeDeCourseStateEntity.self).filter(predicate).toModels()
}
func getStateForIngredient(_ ingredientID: String, email: String) -> Results<ListeDeCourseStateEntity>{
let realm = try! Realm()
let predicate = NSPredicate(format: "ingredientRef.id = '"+ingredientID+"' AND parentID = '"+email+"'")
return realm.objects(ListeDeCourseStateEntity.self).filter(predicate)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment