Tuesday, 29 June 2021

How can i copy pouchdb 0000003.log file to ionic 5 and retrieve data?

My scenario is to use pouch db data in ionic and i successfully added pouch db package to ionic and created a sample and it worked fine. now i have a scenario i have the below file enter image description here

000003.log in which i have all the data . But in ionic it is storing in the indexdb so how can i use this 000003.log data and copy it to indexdb or is there any way copy the contents ?

below is my app code

import { Injectable } from '@angular/core';
import PouchDB from 'pouchdb';

@Injectable({
  providedIn: 'root'
})
export class DataService {

  private database: any;
    private myNotes: any;

  constructor() {
        this.database = new PouchDB('my-notes');
    }

  public addNote(theNote: string): Promise<string> {
        const promise = this.database
            .put({
                _id: ('note:' + (new Date()).getTime()),
                note: theNote
            })
            .then((result): string => (result.id));

        return (promise);
    }

  getMyNotes() {
        return new Promise(resolve => {
            let _self = this;
            this.database.allDocs({
                include_docs: true,
                attachments: true
            }).then(function (result) {
                // handle result
                _self.myNotes = result.rows;
                console.log("Results: " + JSON.stringify(_self.myNotes));
                resolve(_self.myNotes);

            }).catch(function (err) {
                console.log(err);
            });
        });
    }

How to can export/Import the existing database in ionic app do i have to store in file system or indexdb ?



from How can i copy pouchdb 0000003.log file to ionic 5 and retrieve data?

No comments:

Post a Comment