-
Notifications
You must be signed in to change notification settings - Fork 76
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
filter results of pouch adapter query by correct type #194
filter results of pouch adapter query by correct type #194
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this solution, but another way to go might be to add extra parameters for the find selector. This will give some extra requirements on the needed index, which might be hard to get right. But this would put the filtering on the pouch/couch side, which could be worth something.
But this simpler solution could be good to try first?
@@ -351,7 +351,15 @@ export default DS.RESTAdapter.extend({ | |||
queryParams.sort = this._buildSort(query.sort); | |||
} | |||
|
|||
return db.find(queryParams).then(pouchRes => db.rel.parseRelDocs(recordTypeName, pouchRes.docs)); | |||
var idType = type.documentType || recordTypeName; | |||
var recordTypeNameRegex = new RegExp('^' + idType + '_[0-3]'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if a regex is really the right way to go here. Feels a bit overkill. But using the normal way to parse the ID with parseDocID might also be too much. A id.startsWith(idType + '') might be enough here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, maybe babel does not have polyfills yet for startsWith by default? So the RegExp should probably be ok. Technically the idType should be escaped, but the characters that would need escaping would probably not be correct Ember Model names
A bit late now, but a comment nonetheless. This solution makes essentially A solution more along what has been suggested in #168 makes more sense. What we ended up implementing in our project is to actually have a |
right now when using
query
, the ember-pouch adapter actually returns all document types from the pouchdb that match the selector...