Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async checkIfUpdateScriptRequired() {
const usersDb = new PouchDB('users');
const response = await usersDb.allDocs({ include_docs: true });
const usernames = response
.rows
.map(row => row.doc)
.filter(doc => doc.hasOwnProperty('username'))
.map(doc => doc.username);
for (const username of usernames) {
const userDb = await new PouchDB(username);
// Use try in case this is an old account where info doc was not created.
let infoDoc = { _id: '', atUpdateIndex: 0 };
try {
infoDoc = await userDb.get('info');
} catch (e) {
await userDb.put({ _id: 'info', atUpdateIndex: 0 });
infoDoc = await userDb.get('info');
}
const atUpdateIndex = infoDoc.hasOwnProperty('atUpdateIndex') ? infoDoc.atUpdateIndex : 0;
const lastUpdateIndex = updates.length - 1;
if (lastUpdateIndex !== atUpdateIndex) {
this.router.navigate(['/update']);
}
}
}
asyncTest(async done => {
expect.assertions(3);
const db = new PouchDBModule('test');
const { rev } = await db.post({ _id: 'test', a: 'moo' });
await db.putAttachment(
'test',
'att.txt',
rev,
Buffer.from('Moo?', 'utf8'),
'text/plain'
);
const App = () => (
do {
expect(format(attachments['att.txt'].data)).toBe(value1);
db.putAttachment(
async getAllUsersDocs(username?: string) {
const userDB = username || await this.getLoggedInUser();
const DB = new PouchDB(userDB);
try {
const result = await DB.allDocs({
include_docs: true,
attachments: true
});
return result;
} catch (err) {
console.log(err);
}
}
async markDocsAsUploaded(replicatedDocIds, username) {
import PouchDB from "pouchdb";
import PouchDBFind from "pouchdb-find";
import { VolInfo } from "../types";
import { getIPC } from "../utils";
PouchDB.plugin(PouchDBFind);
const db: PouchDB.Database = new PouchDB("vols");
db.createIndex({
index: {
fields: ["vol", "id"]
}
});
class VolDB {
public init = async () => {
const ipc = await getIPC();
const vols = ipc.getPreloadVols();
console.time("save");
await this.saveVols(vols);
console.timeEnd("save");
await this.getLatestVol();
};
return Promise.resolve().then(() => {
const artists = new PouchDB('artists');
return artists.allDocs({
include_docs: false,
startkey: 'library/',
endkey: 'library/\uffff'
});
}).then((docs) => {
return {
constructor: function (localDbName, remoteDbLocation, changesCallback) {
if (!localDbName || typeof localDbName !== 'string') {
throw new Error('missing localDbName parameter');
}
if (!remoteDbLocation || typeof remoteDbLocation !== 'string') {
throw new Error('missing remoteDbLocation parameter');
}
this.remoteDbLocation = remoteDbLocation;
this._onChangesHandler = changesCallback;
this.db = new PouchDB(localDbName);
this.remoteDb = new PouchDB(remoteDbLocation);
},
constructor(props) {
this.databaseName = 'tangy-class'
Object.assign(this, props)
this.userDB = new PouchDB(this.databaseName)
}
export const deleteAllImages = () => {
const pouchDB = new PouchDB('offLine', { auto_compaction: true })
return pouchDB.destroy()
}
constructor(
authenticationService: AuthenticationService,
loc: Loc,
userService: UserService,
private http: Http
) {
this.loc = loc;
this.userService = userService;
this.userDB = new PouchDB
(authenticationService.getCurrentUserDBPath());
}
async getMyLocationVisits() {
protected async fetchTrack (id: string): Promise {
const Track = new PouchDB<track>('tracks');
const track = await Track.get(id);
return {
type: this.RESOLVE_ALBUM,
track
}
}
/**