Use one database

This will make backup/restore operations less complicated.
This commit is contained in:
Timothy Farrell 2018-06-26 08:24:42 -05:00
parent d455ee29f6
commit 28e4fef2d2
4 changed files with 10 additions and 6 deletions

View File

@ -1,6 +1,6 @@
import { TypeSpec } from 'pouchorm';
import { PouchDB } from '../services/db.js';
import { PouchDB, db } from '../services/db.js';
import { ImageType } from '../data/image.js';
import { extractID } from '../utils/conversion.js';
@ -68,7 +68,7 @@ class AlbumSpec extends TypeSpec {
// }
}
export const AlbumType = PouchDB.registerType('Album', AlbumSpec);
export const AlbumType = PouchDB.registerType('Album', AlbumSpec, db);
ImageType.subscribe((id, deleted, doc) => {
if (!deleted) {

View File

@ -1,8 +1,8 @@
import { TypeSpec } from 'pouchorm';
import { PouchDB } from '../services/db.js';
import { sha1 } from '../utils/crypto.js';
import { blobToArrayBuffer } from '../utils/conversion.js';
import { PouchDB, db } from '../services/db.js';
class FileSpec extends TypeSpec {
static getUniqueID(doc) {
@ -73,4 +73,4 @@ class FileSpec extends TypeSpec {
// }
}
export const FileType = PouchDB.registerType('File', FileSpec);
export const FileType = PouchDB.registerType('File', FileSpec, db);

View File

@ -1,6 +1,6 @@
import { TypeSpec } from 'pouchorm';
import { PouchDB } from '../services/db.js';
import { PouchDB, db } from '../services/db.js';
import { blobToArrayBuffer, deepAssign } from '../utils/conversion.js';
import { backgroundTask } from '../utils/event.js';
import { FileType } from './file.js';
@ -122,7 +122,7 @@ const processImportables = backgroundTask(async function _processImportables(ima
module.generateThumbnailForImage(image);
}, false);
export const ImageType = PouchDB.registerType('Image', ImageSpec);
export const ImageType = PouchDB.registerType('Image', ImageSpec, db);
ImageType.index('originalDate', ['originalDate', 'id']);

View File

@ -20,3 +20,7 @@ export const PouchDB = core
// )
// )
.plugin(PouchORM);
export const db = new PouchDB('gallery');
self.db = db;