mirror of
https://github.com/Esri/offline-editor-js.git
synced 2025-12-15 15:20:05 +00:00
first step into refactoring attachmentsStore.js
This commit is contained in:
parent
02f913bb43
commit
d5c106fa14
@ -59,8 +59,8 @@ define([], function()
|
|||||||
|
|
||||||
this.retrieve = function(attachmentId, callback)
|
this.retrieve = function(attachmentId, callback)
|
||||||
{
|
{
|
||||||
if(this._db !== null)
|
console.assert(this._db !== null, "indexeddb not initialized");
|
||||||
{
|
|
||||||
var objectStore = this._db.transaction([OBJECT_STORE_NAME]).objectStore(OBJECT_STORE_NAME);
|
var objectStore = this._db.transaction([OBJECT_STORE_NAME]).objectStore(OBJECT_STORE_NAME);
|
||||||
var request = objectStore.get(attachmentId);
|
var request = objectStore.get(attachmentId);
|
||||||
request.onsuccess = function(event)
|
request.onsuccess = function(event)
|
||||||
@ -78,11 +78,12 @@ define([], function()
|
|||||||
console.log(err);
|
console.log(err);
|
||||||
callback(false,err);
|
callback(false,err);
|
||||||
};
|
};
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getAttachmentsByFeatureId = function(featureLayerUrl,objectId,callback)
|
this.getAttachmentsByFeatureId = function(featureLayerUrl,objectId,callback)
|
||||||
{
|
{
|
||||||
|
console.assert(this._db !== null, "indexeddb not initialized");
|
||||||
|
|
||||||
var featureId = featureLayerUrl + "/" + objectId;
|
var featureId = featureLayerUrl + "/" + objectId;
|
||||||
var attachments = [];
|
var attachments = [];
|
||||||
|
|
||||||
@ -106,6 +107,8 @@ define([], function()
|
|||||||
|
|
||||||
this.getAttachmentsByFeatureLayer = function(featureLayerUrl,callback)
|
this.getAttachmentsByFeatureLayer = function(featureLayerUrl,callback)
|
||||||
{
|
{
|
||||||
|
console.assert(this._db !== null, "indexeddb not initialized");
|
||||||
|
|
||||||
var attachments = [];
|
var attachments = [];
|
||||||
|
|
||||||
var objectStore = this._db.transaction([OBJECT_STORE_NAME]).objectStore(OBJECT_STORE_NAME);
|
var objectStore = this._db.transaction([OBJECT_STORE_NAME]).objectStore(OBJECT_STORE_NAME);
|
||||||
@ -128,6 +131,8 @@ define([], function()
|
|||||||
|
|
||||||
this.getAllAttachments = function(callback)
|
this.getAllAttachments = function(callback)
|
||||||
{
|
{
|
||||||
|
console.assert(this._db !== null, "indexeddb not initialized");
|
||||||
|
|
||||||
var attachments = [];
|
var attachments = [];
|
||||||
|
|
||||||
var objectStore = this._db.transaction([OBJECT_STORE_NAME]).objectStore(OBJECT_STORE_NAME);
|
var objectStore = this._db.transaction([OBJECT_STORE_NAME]).objectStore(OBJECT_STORE_NAME);
|
||||||
@ -148,6 +153,8 @@ define([], function()
|
|||||||
|
|
||||||
this.deleteAttachmentsByFeatureId = function(featureLayerUrl,objectId,callback)
|
this.deleteAttachmentsByFeatureId = function(featureLayerUrl,objectId,callback)
|
||||||
{
|
{
|
||||||
|
console.assert(this._db !== null, "indexeddb not initialized");
|
||||||
|
|
||||||
var featureId = featureLayerUrl + "/" + objectId;
|
var featureId = featureLayerUrl + "/" + objectId;
|
||||||
|
|
||||||
var objectStore = this._db.transaction([OBJECT_STORE_NAME],"readwrite").objectStore(OBJECT_STORE_NAME);
|
var objectStore = this._db.transaction([OBJECT_STORE_NAME],"readwrite").objectStore(OBJECT_STORE_NAME);
|
||||||
@ -172,8 +179,8 @@ define([], function()
|
|||||||
|
|
||||||
this.delete = function(attachmentId, callback)
|
this.delete = function(attachmentId, callback)
|
||||||
{
|
{
|
||||||
if(this._db !== null)
|
console.assert(this._db !== null, "indexeddb not initialized");
|
||||||
{
|
|
||||||
var request = this._db.transaction([OBJECT_STORE_NAME],"readwrite")
|
var request = this._db.transaction([OBJECT_STORE_NAME],"readwrite")
|
||||||
.objectStore(OBJECT_STORE_NAME)
|
.objectStore(OBJECT_STORE_NAME)
|
||||||
.delete(attachmentId);
|
.delete(attachmentId);
|
||||||
@ -185,17 +192,12 @@ define([], function()
|
|||||||
{
|
{
|
||||||
callback(false,err);
|
callback(false,err);
|
||||||
};
|
};
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
callback(false,null);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.deleteAll = function(callback)
|
this.deleteAll = function(callback)
|
||||||
{
|
{
|
||||||
if(this._db !== null)
|
console.assert(this._db !== null, "indexeddb not initialized");
|
||||||
{
|
|
||||||
var request = this._db.transaction([OBJECT_STORE_NAME],"readwrite")
|
var request = this._db.transaction([OBJECT_STORE_NAME],"readwrite")
|
||||||
.objectStore(OBJECT_STORE_NAME)
|
.objectStore(OBJECT_STORE_NAME)
|
||||||
.clear();
|
.clear();
|
||||||
@ -207,15 +209,12 @@ define([], function()
|
|||||||
{
|
{
|
||||||
callback(false,err);
|
callback(false,err);
|
||||||
};
|
};
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
callback(false,null);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.replaceFeatureId = function(featureLayerUrl, oldId, newId, callback)
|
this.replaceFeatureId = function(featureLayerUrl, oldId, newId, callback)
|
||||||
{
|
{
|
||||||
|
console.assert(this._db !== null, "indexeddb not initialized");
|
||||||
|
|
||||||
var featureId = featureLayerUrl + "/" + oldId;
|
var featureId = featureLayerUrl + "/" + oldId;
|
||||||
|
|
||||||
var objectStore = this._db.transaction([OBJECT_STORE_NAME],"readwrite").objectStore(OBJECT_STORE_NAME);
|
var objectStore = this._db.transaction([OBJECT_STORE_NAME],"readwrite").objectStore(OBJECT_STORE_NAME);
|
||||||
@ -245,7 +244,8 @@ define([], function()
|
|||||||
|
|
||||||
this.getUsage = function(callback)
|
this.getUsage = function(callback)
|
||||||
{
|
{
|
||||||
if(this._db !== null){
|
console.assert(this._db !== null, "indexeddb not initialized");
|
||||||
|
|
||||||
var usage = { sizeBytes: 0, attachmentCount: 0 };
|
var usage = { sizeBytes: 0, attachmentCount: 0 };
|
||||||
|
|
||||||
var transaction = this._db.transaction([OBJECT_STORE_NAME])
|
var transaction = this._db.transaction([OBJECT_STORE_NAME])
|
||||||
@ -275,11 +275,6 @@ define([], function()
|
|||||||
{
|
{
|
||||||
callback(null,err);
|
callback(null,err);
|
||||||
};
|
};
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
callback(null,null);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.init = function(callback)
|
this.init = function(callback)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user