Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give .load() the ability to accept strings #73

Open
cepm-nate opened this issue Jan 25, 2018 · 1 comment
Open

Give .load() the ability to accept strings #73

cepm-nate opened this issue Jan 25, 2018 · 1 comment

Comments

@cepm-nate
Copy link

cepm-nate commented Jan 25, 2018

PouchDB and pouchdb-replication-stream included via script tags at top of page.

<script src="./lib/pouchdb-6.3.4.min.js"></script>
<script src="./lib/pouchdb.find.js"></script>
<script src="./lib/pouchdb.upsert.min.js"></script>
<script src="./lib/pouchdb.authentication-0.5.5.min.js"></script>
<script src="./lib/pouchdb.erase.min.js"></script>
<script src="./lib/pouchdb.replication-stream.js"></script>
<script src="./lib/pouchdb-cordova-sqlite-2.02.js"></script>

Calling targetDB.load(sourceString) results in an error of readableStream.pipe is not a function.

mm.pdb.pouch = new PouchDB('pdb', {revs_limits: 20,adapter: 'cordova-sqlite'});
// Receive zip file from server, extract it into a text file, then
mm.pdb.pouch.load(dbDumpTxt
).then(function(r){
	console.log('Loaded from file!');
	mm.pdb.initSyncing();
}).catch(function(e){
	console.error('Could not restore from file, proceeding with normal sync. Message:',e.message);
});

I can use pouchdb-load with the same dbDumpTxt file, but it seems to cause a slew of network activity following the .load (even with proper proxy option supplied), so I'm trying to see if pouchdb-replication-stream's .load() is better.

Has anyone else run into this .pipe() issue?

Looks like it's because .load() expects a STREAM, not a STRING. I've just dug into learning about streams (Node.js, BufferedStreams, HighLander, mozilla developer versiosn), and it looks like they are slightly different. Any chance that this .load() function could be modified to also accept an input string, as that is what .dump() creates?

@cepm-nate cepm-nate changed the title Getting 'readableStream.pipe' is not a function, in the console Getting 'readableStream.pipe' is not a function Jan 25, 2018
@cepm-nate cepm-nate changed the title Getting 'readableStream.pipe' is not a function Error: 'readableStream.pipe' is not a function (when using in a browser) Jan 25, 2018
@cepm-nate cepm-nate changed the title Error: 'readableStream.pipe' is not a function (when using in a browser) Give .load() the ability to accept strings Jan 25, 2018
@claytonk
Copy link

claytonk commented Apr 24, 2020

Old thread, but this needs clarification. They probably should have clarified this in the ReadMe but this can only work server-side (node.js) since javascript has no ability to save files on the client side. Based on your code, it looks like you were trying to use this for an app (as I was when I came across the library) but it won't work without a server-side connection to store files. Unless somebody knows of some magic I don't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants