mirror of
https://github.com/donl/slouch.git
synced 2026-05-27 06:14:04 -06:00
* feat(cookie): request-wrapper * test(request-wrapper): 100% coverage * test(browser): 100% coverage * refactor(request-class): rename to enhanced-request * feat(get-session) * feat(enhanced-request): full response * refactor(enhanced-request): enhanced opts * feat(example): authentication
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
var Attachment = function (slouch) {
|
|
this._slouch = slouch;
|
|
};
|
|
|
|
// TODO
|
|
// Attachment.prototype.create = function (dbName, docId, attachmentName, data, contentType, rev) {
|
|
// var formData = {
|
|
// custom_file: {
|
|
// value: data,
|
|
// options: {
|
|
// filename: attachmentName,
|
|
// contentType: contentType
|
|
// }
|
|
// }
|
|
// };
|
|
//
|
|
// return this._slouch._req({
|
|
// uri: this._slouch._url + '/' + dbName + '/' + docId + '/' + attachmentName +
|
|
// '?rev=' + encodeURIComponent(rev),
|
|
// method: 'PUT',
|
|
// // raw: true,
|
|
// // encoding: null,
|
|
// formData: formData
|
|
// }).then(function (response) {
|
|
// return response.body;
|
|
// });
|
|
// };
|
|
|
|
Attachment.prototype.get = function (dbName, docId, attachmentName) {
|
|
return this._slouch._req({
|
|
uri: this._slouch._url + '/' + dbName + '/' + docId + '/' + attachmentName,
|
|
method: 'GET',
|
|
raw: true,
|
|
encoding: null
|
|
}).then(function (response) {
|
|
return response.body;
|
|
});
|
|
};
|
|
|
|
Attachment.prototype.destroy = function (dbName, docId, attachmentName, rev) {
|
|
return this._slouch._req({
|
|
uri: this._slouch._url + '/' + dbName + '/' + docId + '/' + attachmentName,
|
|
method: 'DELETE',
|
|
qs: {
|
|
rev: rev
|
|
}
|
|
});
|
|
};
|
|
|
|
module.exports = Attachment;
|