This repository has been archived by the owner on Mar 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
122 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use strict'; | ||
|
||
const Loki = require('lokijs'), | ||
BbPromise = require('bluebird'), | ||
AzuriteTableResponse = require('./../../model/table/AzuriteTableResponse'), | ||
Tables = require('./../Constants').TableStorageTables, | ||
env = require('./../../core/env'); | ||
|
||
|
||
|
||
class TableStorageManager { | ||
constructor() { | ||
} | ||
|
||
init() { | ||
this.db = BbPromise.promisifyAll(new Loki(env.azuriteDBPathTable, { autosave: true, autosaveInterval: 5000 })); | ||
return fsn.statAsync(env.azuriteDBPathTable) | ||
.then((stat) => { | ||
return this.db.loadDatabaseAsync({}); | ||
}) | ||
.then((data) => { | ||
if (!this.db.getCollection(Tables.Tables)) { | ||
this.db.addCollection(Tables.Tables); | ||
} | ||
return this.db.saveDatabaseAsync(); | ||
}) | ||
.catch((e) => { | ||
if (e.code === 'ENOENT') { | ||
// No DB has been persisted / initialized yet. | ||
this.db.addCollection(Tables.Tables); | ||
return this.db.saveDatabaseAsync(); | ||
} | ||
// This should never happen! | ||
console.error(`Failed to initialize database at "${env.azuriteDBPathTable}"`); | ||
throw e; | ||
}); | ||
} | ||
|
||
createTable(request) { | ||
return BbPromise.resolve(new AzuriteTableResponse()); | ||
} | ||
} | ||
|
||
module.exports = new TableStorageManager(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
class TableProxy { | ||
constructor(entity) { | ||
this._ = entity; | ||
} | ||
|
||
/** | ||
* Returns the odata representation of the table entity. | ||
* | ||
* @param {any} odata is (nometadata|minimalmetadata|fullmetadata) | ||
* @returns | ||
* @memberof TableProxy | ||
*/ | ||
odata(mode) { | ||
return this._; | ||
} | ||
} | ||
|
||
module.exports = TableProxy; |