Skip to content

Commit 9031769

Browse files
committed
Added the erase method, very useful in tests
1 parent 7435a20 commit 9031769

15 files changed

+58
-25
lines changed

js/main/Db.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="../../typings/tsd.d.ts" />
1+
/// <reference path="../../jsdb/typings/tsd.d.ts" />
22
export = Db;
33
declare class Db {
44
baseUrl: string;

js/main/Db.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
var __extends = (this && this.__extends) || function (d, b) {
33
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
44
function __() { this.constructor = d; }
5-
__.prototype = b.prototype;
6-
d.prototype = new __();
5+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
76
};
87
var Firebase = require('firebase');
98
var PromiseModule = require('es6-promise');
@@ -955,4 +954,3 @@ var Db;
955954
})(internal = Db.internal || (Db.internal = {}));
956955
})(Db || (Db = {}));
957956
module.exports = Db;
958-
//# sourceMappingURL=Db.js.map

js/main/Db2.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="../../typings/tsd.d.ts" />
1+
/// <reference path="../../jsdb/typings/tsd.d.ts" />
22
export = Db;
33
declare class Db {
44
/**

js/main/Db2.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
var __extends = (this && this.__extends) || function (d, b) {
33
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
44
function __() { this.constructor = d; }
5-
__.prototype = b.prototype;
6-
d.prototype = new __();
5+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
76
};
87
var Firebase = require('firebase');
98
var SocketIOClient = require('socket.io-client');
@@ -1054,4 +1053,3 @@ var Db;
10541053
})(internal = Db.internal || (Db.internal = {}));
10551054
})(Db || (Db = {}));
10561055
module.exports = Db;
1057-
//# sourceMappingURL=Db2.js.map

js/main/Db3.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ declare module Db {
105105
* Reset the internal state of the db, purging the cache and closing al listeners.
106106
*/
107107
reset(): any;
108+
/**
109+
* Deletes all the data from the db, without sending any event, and resets the internal state.
110+
*/
111+
erase(): any;
108112
}
109113
/**
110114
* Implementation of {@link IDbOperations}.
@@ -115,6 +119,7 @@ declare module Db {
115119
fork(conf: any): IDb3Static;
116120
load<T extends Entity>(url: string): T;
117121
reset(): void;
122+
erase(): void;
118123
}
119124
/**
120125
* Binding between parent and {@link embedded} entities.

js/main/Db3.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
/**
2-
* TSDB version : VERSION_TAG
2+
* TSDB version : 20150920_204425_master_1.0.0_2207036
33
*/
44
var __extends = (this && this.__extends) || function (d, b) {
55
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
66
function __() { this.constructor = d; }
7-
__.prototype = b.prototype;
8-
d.prototype = new __();
7+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
98
};
109
var Firebase = require('firebase');
1110
var PromiseModule = require('es6-promise');
1211
var Promise = PromiseModule.Promise;
13-
var Version = 'VERSION_TAG';
12+
var Version = '20150920_204425_master_1.0.0_2207036';
1413
/**
1514
* The main Db module.
1615
*/
@@ -110,6 +109,10 @@ var Db;
110109
DbOperations.prototype.reset = function () {
111110
this.state.reset();
112111
};
112+
DbOperations.prototype.erase = function () {
113+
this.reset();
114+
new Firebase(this.state.getUrl()).remove();
115+
};
113116
return DbOperations;
114117
})();
115118
Internal.DbOperations = DbOperations;
@@ -3062,4 +3065,3 @@ var defaultDb = null;
30623065
*/
30633066
var entEvent = new Db.Utils.WeakWrap();
30643067
module.exports = Db;
3065-
//# sourceMappingURL=Db3.js.map

js/main/Db3.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/main/jsdb.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ declare module 'jsdb' {
108108
* Reset the internal state of the db, purging the cache and closing al listeners.
109109
*/
110110
reset(): any;
111+
/**
112+
* Deletes all the data from the db, without sending any event, and resets the internal state.
113+
*/
114+
erase(): any;
111115
}
112116
/**
113117
* Implementation of {@link IDbOperations}.
@@ -118,6 +122,7 @@ declare module 'jsdb' {
118122
fork(conf: any): IDb3Static;
119123
load<T extends Entity>(url: string): T;
120124
reset(): void;
125+
erase(): void;
121126
}
122127
/**
123128
* Binding between parent and {@link embedded} entities.

js/test/Db2Tests.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/// <reference path="../../typings/tsd.d.ts" />
1+
/// <reference path="../../jsdb/typings/tsd.d.ts" />

js/test/Db2Tests.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
var __extends = (this && this.__extends) || function (d, b) {
33
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
44
function __() { this.constructor = d; }
5-
__.prototype = b.prototype;
6-
d.prototype = new __();
5+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
76
};
87
var _this = this;
98
var Db = require('../main/Db2');
@@ -934,4 +933,3 @@ describe('Db2 Tests', function () {
934933
// --- Needed
935934
// TODO binding and live update for collections
936935
});
937-
//# sourceMappingURL=Db2Tests.js.map

js/test/Db3Tests.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
var __extends = (this && this.__extends) || function (d, b) {
22
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
33
function __() { this.constructor = d; }
4-
__.prototype = b.prototype;
5-
d.prototype = new __();
4+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
65
};
76
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
87
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
@@ -2097,4 +2096,3 @@ describe('Db3 >', function () {
20972096
});
20982097
});
20992098
});
2100-
//# sourceMappingURL=Db3Tests.js.map

js/test/DbTests.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/// <reference path="../../typings/tsd.d.ts" />
1+
/// <reference path="../../jsdb/typings/tsd.d.ts" />

js/test/DbTests.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
var __extends = (this && this.__extends) || function (d, b) {
33
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
44
function __() { this.constructor = d; }
5-
__.prototype = b.prototype;
6-
d.prototype = new __();
5+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
76
};
87
var _this = this;
98
//declare var MockFirebase;
@@ -588,4 +587,3 @@ describe('Db Tests', function () {
588587
});
589588
*/
590589
});
591-
//# sourceMappingURL=DbTests.js.map

src/main/Db3.ts

+10
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ module Db {
201201
* Reset the internal state of the db, purging the cache and closing al listeners.
202202
*/
203203
reset();
204+
205+
/**
206+
* Deletes all the data from the db, without sending any event, and resets the internal state.
207+
*/
208+
erase();
204209
}
205210

206211
/**
@@ -225,6 +230,11 @@ module Db {
225230
reset() {
226231
this.state.reset();
227232
}
233+
234+
erase() {
235+
this.reset();
236+
new Firebase(this.state.getUrl()).remove();
237+
}
228238
}
229239

230240
/**

todo.md

+21
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,24 @@ Write an interface for database configuration
5353
---------------------------------------------
5454

5555

56+
Complete loading by url
57+
-----------------------
58+
59+
It could use the existing methods, simply needs to build the metadata chain from url segments
60+
rather than from calls to getters. This however limits the scope, cause for example it could be
61+
hard to go inside a collection (true also for metadata navigation).
62+
63+
Otherwise, it could work like the current one based on metadata, calling child creation.
64+
65+
Otherwise, it could be the current one that become string based (to create children it only needs
66+
the name, that is a string and is also the path segment of the url).
67+
68+
69+
Cache and cache cleaning
70+
------------------------
71+
72+
A simple initial implementation could be based on roots only, where only rooted entities
73+
are cached and managed, with a periodic pruning of unused children events.
74+
75+
This would automatically grant the peristence of parent events as long as child events are active.
76+

0 commit comments

Comments
 (0)