Commit dafc0c70 authored by Romain Courteaud's avatar Romain Courteaud

Add SHA storage (create only new document)

parent bd52f34e
......@@ -174,6 +174,7 @@ module.exports = function (grunt) {
'node_modules/rusha/rusha.js',
'src/jio.storage/replicatestorage.js',
'src/jio.storage/shastorage.js',
'src/jio.storage/uuidstorage.js',
'src/jio.storage/memorystorage.js',
'src/jio.storage/localstorage.js',
......
/*
* Copyright 2015, Nexedi SA
* Released under the LGPL license.
* http://www.gnu.org/licenses/lgpl.html
*/
/*jslint nomen: true*/
/*global Rusha*/
/**
* JIO Sha Storage. Type = 'sha'.
*/
(function (Rusha) {
"use strict";
var rusha = new Rusha();
function ShaStorage(spec) {
this._sub_storage = jIO.createJIO(spec.sub_storage);
}
ShaStorage.prototype.post = function (param) {
return this._sub_storage.put(
rusha.digestFromString(JSON.stringify(param)),
param
);
};
ShaStorage.prototype.get = function () {
return this._sub_storage.get.apply(this._sub_storage, arguments);
};
ShaStorage.prototype.remove = function () {
return this._sub_storage.remove.apply(this._sub_storage, arguments);
};
ShaStorage.prototype.hasCapacity = function () {
return this._sub_storage.hasCapacity.apply(this._sub_storage, arguments);
};
ShaStorage.prototype.buildQuery = function () {
return this._sub_storage.buildQuery.apply(this._sub_storage, arguments);
};
ShaStorage.prototype.getAttachment = function () {
return this._sub_storage.getAttachment.apply(this._sub_storage, arguments);
};
ShaStorage.prototype.putAttachment = function () {
return this._sub_storage.putAttachment.apply(this._sub_storage, arguments);
};
ShaStorage.prototype.removeAttachment = function () {
return this._sub_storage.removeAttachment.apply(this._sub_storage,
arguments);
};
ShaStorage.prototype.allAttachments = function () {
return this._sub_storage.allAttachments.apply(this._sub_storage, arguments);
};
ShaStorage.prototype.repair = function () {
return this._sub_storage.repair.apply(this._sub_storage, arguments);
};
jIO.addStorage('sha', ShaStorage);
}(Rusha));
This diff is collapsed.
......@@ -39,6 +39,7 @@
<script src="jio.storage/indexeddbstorage.tests.js"></script>
<script src="jio.storage/uuidstorage.tests.js"></script>
<script src="jio.storage/replicatestorage.tests.js"></script>
<script src="jio.storage/shastorage.tests.js"></script>
<!--script src="jio.storage/indexstorage.tests.js"></script-->
<!--script src="jio.storage/dropboxstorage.tests.js"></script-->
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment