-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Not Issue] Couple of questions on the framework #59
Comments
Hi @anoop4real
|
Hi, Thanks for the reply,
For example: my Country data looks like apiVersion/Countries/(Country1, Country2...)/States... So if I set up a State object, the state object should know the path till the particular country document Right now I am creating the reference dynamically and the State object doesnt know it.
Hope I am able to explain it. |
It can be given dynamically by using https://github.com/1amageek/Pring/blob/master/Pring/Object.swift#L222 |
Thanks again, I really appreciate your prompt replies...
what is the equivalent in Pring? In the sample, most of the places, you are directly getting data by providing id. Lets say below are my classes, how can I get all countries and their respective states
I dont get something like |
Use DataSource for Collection get https://github.com/1amageek/Pring#datasource // get
let dataSource = County
Country.query.dataSource().onCompleted( { _, _ in
}).get()
// listen
let dataSource = County.query.dataSource().onCompleted( { _, _ in
}).listen()
// Query
Country.where("", "").dataSource()
// SubCollection
let country: Country = Country()
country.states.query.dataSource() |
Hi @anoop4real |
Hello @1amageek Below is what I am trying....see if this is the way..
|
@objcMembers
class State: Object{
dynamic var name: String?
dynamic var capital: String?
dynamic var provine: Relation<Province> = .init()
}
@objcMembers
class Province:Object {
dynamic var name: String?
} Please look at READEME https://github.com/1amageek/Pring#datasource self.dataSource = User.order(by: \User.updatedAt).dataSource()
.on({ [weak self] (snapshot, changes) in
guard let tableView: UITableView = self?.tableView else { return }
debugPrint("On")
switch changes {
case .initial:
tableView.reloadData()
case .update(let deletions, let insertions, let modifications):
tableView.beginUpdates()
tableView.insertRows(at: insertions.map { IndexPath(row: $0, section: 0) }, with: .automatic)
tableView.deleteRows(at: deletions.map { IndexPath(row: $0, section: 0) }, with: .automatic)
tableView.reloadRows(at: modifications.map { IndexPath(row: $0, section: 0) }, with: .automatic)
tableView.endUpdates()
case .error(let error):
print(error)
}
})
.on(parse: { (snapshot, user, done) in
user.group.get({ (group, error) in
done(user)
})
})
.onCompleted({ (snapshot, users) in
debugPrint("completed")
})
.listen() |
Hello @1amageek I am not sure whether you are able to get my query. Did you have a look at my Stackoverflow post. In the approach explained there, I get all the Countries , states and provinces in one shot through recursive loop and assign those the right hierarchy. ie if I take a Country object, the states and provinces comes along. Now here are the questions. Read my comments ** in the below code , your readme is not telling me how to do this.
|
First of all its an interesting framework and I need a few information to see if I can try it out.
For me the firebase paths are already defined. If that is the case, how can I tell the object to use a particular path? Right now you are using version/modelversion/modelName, which wont work in my case.
I have a nested subcollection usecases in my project as explained here (https://stackoverflow.com/questions/54751023/swift-firestore-sub-collections-custom-objects-and-listeners/54751305#comment96528634_54751305) will this framework ease my flow?.
The text was updated successfully, but these errors were encountered: