-
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
Fetching actual attachment data from an "ember-pouch" model #164
Comments
Thanks for pointing this out, this really should be supported. Something like the following should be added to getAttachment(model, attr) {
let type = model.constructor.modelName
let id = model.get('id')
let name = model.get(`${attr}.name`)
return this.get('db').rel.getAttachment(this.getRecordTypeName(type), id, name)
} This would allow usage as follows:
Feel like doing a PR that adds this with a test? |
@stevebest do you agree with this? |
Looks fine to me. My use case doesn't access the attachment data after it's been uploaded. I use a rather dirty hack to get their URLs for |
Hi! |
@handegar I submitted the initial implementation for attachments, happy to help out. |
I'm currently working (issue #229) with attachments myself and ran into this issue. As anyone made progress on this subject? I'm able to save attachments to my models in CouchDB (thank you @jlami!), but now I need to get the content back for display purposes. |
I haven't tested this. But it looks like I think you might need to change it to getAttachment(model, attr) {
let type = model.constructor
let id = model.get('id')
let name = model.get(`${attr}.name`)
return this.get('db').rel.getAttachment(this.getRecordTypeName(type), id, name)
} |
Good spot @jlami, it works. Thanks again! 👍 |
Good to hear, if it works as expected we could make a PR out of this. |
@bastientanesie I got stuck on the same problem but I can't solve it. Could you please give some more details how you solved it? |
Sure @mbernwieser, here's what I came up with in my model: getAttachment(model, attr) {
return this.get('db').rel.getAttachment(
this.getRecordTypeName(model.constructor),
model.get('id'),
model.get(`${attr}.name`)
);
} The trick is to use |
Thanks @bastientanesie, I got it working 😄 |
I have difficulties fetching the actual attachment-data from my PouchDB/CouchDB when using an
ember-pouch
model with aDS.attr("attachments")
property.My model:
I can upload data without issues (confirmed by inspecting the CouchDB directly), but when I try to fetch back the data via my model, all I get is a stub, ie. the
data
-field isundefined
and thestub
-flag istrue
.Is there something I have overlooked here?
According to the PouchDB API spec, one must explicitly specify that the actual attachments data shall be included in the response via the
{attachments: true}
option in thedb.get(..)
call (ref: https://pouchdb.com/guides/attachments.html). Is this relevant?I am currently using Ember-Pouch version 4.2.2 and
PouchDB.version
says 6.1.0.The text was updated successfully, but these errors were encountered: