Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function _create(): Promise {
console.log('DatabaseService: creating database..');
const db = await RxDB.create({
name: 'heroes',
adapter: useAdapter,
queryChangeDetection: true
// password: 'myLongAndStupidPassword' // no password needed
});
console.log('DatabaseService: created database');
(window as any).db = db; // write to window for debugging
// show leadership in title
db.waitForLeadership()
.then(() => {
console.log('isLeader now');
document.title = 'â™› ' + document.title;
});
// create collections
async initDb(config: NgxRxdbConfig) {
console.log('INIT DB');
try {
const db: RxDatabase = await RxDB.create({
...DEFAULT_CONFIG,
...config
});
this._dbInstance = db;
console.log(this.db);
console.log('RxdbService: created database');
// also can create collections from root config
if (config && config.options && config.options.schemas) {
await this.initCollections(config.options.schemas);
console.log('RxdbService: created collections bulk');
}
console.log(config);
if (config && config.options && config.options.dumpPath) {
// fetch dump json
const dump = await (await fetch(config.options.dumpPath)).json();
async function _create(): Promise {
console.log('DatabaseService: creating database..');
const db = await RxDB.create({
name: 'heroes',
adapter: useAdapter,
queryChangeDetection: true
// password: 'myLongAndStupidPassword' // no password needed
});
console.log('DatabaseService: created database');
(window as any)['db'] = db; // write to window for debugging
// show leadership in title
db.waitForLeadership()
.then(() => {
console.log('isLeader now');
document.title = 'â™› ' + document.title;
});
// create collections
async function _create(): Promise {
await loadRxDBPlugins();
console.log('DatabaseService: creating database..');
const db = await RxDB.create({
name: 'angularheroes',
adapter: 'idb',
queryChangeDetection: true
// password: 'myLongAndStupidPassword' // no password needed
});
console.log('DatabaseService: created database');
(window as any)['db'] = db; // write to window for debugging
// show leadership in title
db.waitForLeadership()
.then(() => {
console.log('isLeader now');
document.title = 'â™› ' + document.title;
});
// create collections
async function run() {
heroesList.innerHTML = 'Create database..';
const db = await RxDB.create({
name: getDatabaseName(),
adapter: 'idb'
});
window.db = db;
// display crown when tab is leader
db.waitForLeadership().then(function () {
document.title = 'â™› ' + document.title;
leaderIcon.style.display = 'block';
});
heroesList.innerHTML = 'Create collection..';
const collection = await db.collection({
name: 'hero',
schema: heroSchema
});