polymerelements / app-pouchdb Goto Github PK
View Code? Open in Web Editor NEWCustom Elements for working with PouchDB.
Custom Elements for working with PouchDB.
I'm using app-pouchdb-sync to upload documents from local database to remote couchdb using this code in src/my-app.html :
<app-pouchdb-sync src="localdb" target="http://username:[email protected]/remotedb" bidirectional="">
</app-pouchdb-sync>
and in the web console keeps appearing this errors:
https://site.example.com/src/localdb/ 404 ()
like if src were a "remote database"
I'm using pouchdb-5.3.2 and app-pouchdb-0.9.1
I am working with this element and i'm confuse with how we can interact with a specified DB.
Like to properly insert/delete document from JS code or to set DB documents if empty.
A working demo or some more examples in documentation would be great.
app-pouchdb-index
gives exception: TypeError: this.db.createIndex is not a function
when attempting to use it.
app-pouchdb-index
element is working and PouchDB indexes created.
No indexes are created and element throws error:
TypeError: this.db.createIndex is not a function
.__createIndex()
app-pouchdb-index.html.js:56
._complexObserverEffect()
polymer.html.js:1634
Polymer.Bind._modelApi._effectEffects()
polymer.html.js:1469
Polymer.Bind._modelApi._propertySetter()
polymer.html.js:1453
Polymer.Bind._modelApi.__setProperty()
polymer.html.js:1462
._computeEffect()
polymer.html.js:1647
Polymer.Bind._modelApi._effectEffects()
polymer.html.js:1469
Polymer.Bind._modelApi._propertySetter()
polymer.html.js:1453
Polymer.Bind._modelApi.__setProperty()
polymer.html.js:1462
._applyConfig()
polymer.html.js:2072
._afterClientsReady()
polymer.html.js:2066
._ready()
polymer-mini.html.js:62
._readyClients()
polymer-mini.html.js:70
._ready()
polymer-mini.html.js:58
._readyClients()
polymer-mini.html.js:70
._ready()
polymer-mini.html.js:58
._tryReady()
polymer-mini.html.js:48
._initFeatures()
polymer.html.js:4090
Polymer.Base.createdCallback()
polymer-micro.html.js:190
created()
webcomponents-lite.js:2217
upgradeWithDefinition()
webcomponents-lite.js:2185
upgrade()
webcomponents-lite.js:2173
added()
webcomponents-lite.js:1978
addedSubtree/<()
webcomponents-lite.js:1987
forSubtree/<()
webcomponents-lite.js:1919
findAllElements()
webcomponents-lite.js:1935
findAllElements()
webcomponents-lite.js:1936
findAllElements()
webcomponents-lite.js:1936
forSubtree()
webcomponents-lite.js:1918
addedSubtree()
webcomponents-lite.js:1986
addedNode()
webcomponents-lite.js:1975
upgradeDocument()
webcomponents-lite.js:2136
_forDocumentTree()
webcomponents-lite.js:1964
forDocumentTree()
webcomponents-lite.js:1950
upgradeDocumentTree()
webcomponents-lite.js:2141
bootstrap()
webcomponents-lite.js:2473
<anonimowa>
webcomponents-lite.js:1293
checkDone()
webcomponents-lite.js:1212
loadedImport()
webcomponents-lite.js:1223
importParser.parseImport()
webcomponents-lite.js:1577
importParser.parseLink()
webcomponents-lite.js:1600
importParser.parse()
webcomponents-lite.js:1538
importParser.parseNext()
webcomponents-lite.js:1527
importParser.trackElement/done()
webcomponents-lite.js:1637
I attempted to create one at https://jsbin.com/giyuyeyera/edit?html,console,output but it seems app-pouchdb
elements there don't have their PouchDB
dependency installed.
app-pouchdb-index
and app-pouchdb-query
elements according to https://elements.polymer-project.org/elements/app-pouchdb?active=app-pouchdb-query.Firefox 45.5.1
I have downloaded app-puchdb components through bower. It install pouchdb-5.4.4.
When I import a app-pouchdb-query
I got an error in JavaScript Console:
Uncaught TypeError: Cannot read property 'Promise' of undefined(anonymous function) pouchdb.find.js:4493
The same application works fine when I revert back to pouchdb-5.3.2
Unable to sort based on app-pouchdb-index
The query works.
Error: Cannot sort on field(s) "date" when using the default index
http://plnkr.co/edit/TWChH1i6feesMnDy83OZ?p=preview
Putting the name of the local database in the src, converts the string into a URL.
<app-pouchdb-sync src="localDbName" target="http://ip:port/remoteDb" bidirectional >
tries to create
Pouch.sync('http://localhost:8080/src/localDbName', http://ip:port/remoteDb")
which results in the synchronisation not working.
<app-pouchdb-sync src="localDbName" target="http://ip:port/remoteDb" bidirectional >
is expected to launch
Pouch.sync('localDbName', http://ip:port/remoteDb")
The element converts src into a URL, namely, 'http://localhost:8080/src/localDbName' and thus tries to launch
Pouch.sync('http://localhost:8080/src/localDbName', http://ip:port/remoteDb")
console.log("src= " + src);
<app-pouchdb-sync
src="localDbName"
target="thisNameCanAlsoBeLocal"
bidirectional>
</app-pouchdb-sync>
Alternatively, create a new element
<script>
(function() {
Polymer({
is: 'my-element',
properties: {
src: {
type: String
}
},
ready: function() {
console.log(this.src);
}
});
})();
</script>
And use it from another element
The console should display
Checking in symlinks seems like a potentially tricky thing.
First, tools need to make sure they understand symlinks. Tedium already has to be updated.
Second, I've heard of problems with checking out symlinks on Windows I'm not sure if they're still problematic, but it'd be nice to confirm that the symlinks work on windows.
Third, the symlink will be invalid when this package is Bower installed, because there won't be a ./bower_components
directory.
Are there viable alternate approaches to symlinks?
Perhaps app-pouchdb-storage?
Here it says https://www.polymer-project.org/1.0/toolbox/app-storage, we can even use these elements with authentication against the remote database. Couldn;t find any implementation / or passing user name password options.
Can someone please verify it please. Thanks !
Regards,
Sowmyan
I was trying to build the catalog, but it failed because ../pouchdb/dist/pouchdb.js
isn't found. I did a quick look at the pouchdb
dependency and it doesn't have a dist
folder anymore. version: 6.1.1
It would be nice for app-pouchdb-sync element to emit events on change and error. We'd be able to perform tasks as query refresh, in case of change, or toast a message in case of error.
On each change or error, element should emit events.
No event emited, only log of events is available.
In app-pouchdb-document
there's a fragment where clearly call to this.reset();
is out of scope:
destroy: function() {
this.set('data._deleted', true);
return this.transactionsComplete.then(function() {
return this.reset();
});
},
This causes calls to this function to always fail. Though, the item is deleted from the store.
Not fail :)
Promise rejection due the error.
https://jsbin.com/wiroqef/4/edit?html,js,output
See demo.
Browser independent. It will always fail.
In the AppPouchDBDatabaseBehavior
function __computeDb
has switched arduments. According to db
attribute definition this is computed by __computeDb(dbName, adapter, revsLimit)
however, actual function body is __computeDb: function(name, revsLimit, adapter)
.
It causes error when trying to put anything to the data store:
Uncaught TypeError: Cannot read property '2' of undefined
at traverseRevTree (VM4319 pouchdb.js:3619)
at stem (VM4319 pouchdb.js:3914)
at merge (VM4319 pouchdb.js:3927)
at nextDoc (VM4319 pouchdb.js:5953)
at VM4319 pouchdb.js:5959
at _Map.15._Map.forEach (VM4319 pouchdb.js:2574)
at processDocs (VM4319 pouchdb.js:5933)
at idbProcessDocs (VM4319 pouchdb.js:6331)
at checkDone (VM4319 pouchdb.js:6345)
at IDBRequest.readMetadata (VM4319 pouchdb.js:6355)
This error is caused because of the switch. At this point PouchDB is expecting different parameter. After I switch back this parameters in by bower_components folder my test cases started working.
Install package on Polymer 3.0
Package installed
The package not found:
npm ERR! code ETARGET
npm ERR! notarget No matching version found for @polymer/app-pouchdb@next
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-06-01T22_07_13_684Z-debug.log
app-pouchdb-sync
element appears in the README but is not present in the polymer.elements catalog.
Trying to sync a local pouch with a working coucdb doesn't work. No errors are shown but no replication happens.
app-pouchdb-sync
element appears in the polymer.elements catalog and is properly documented.
It correctly syncs two databases.
Nothing happens when I add app-pouchdb-sync
to a polymer project.
Behavior Polymer.AppPouchDBDatabaseBehavior not found when mixing properties into app-pouchdb-index!
Behavior Polymer.AppPouchDBDatabaseBehavior not found when mixing properties into app-pouchdb-query!
Behavior Polymer.AppPouchDBDatabaseBehavior not found when mixing properties into app-pouchdb-document!
After setting up a remote CouchDB and activating CORS I still get a "Referer header must match host."
error when using app-pouchdb-query
<app-pouchdb-query
db-name="http://localhost:5984/kittens"
selector="_id $gt null"
data="{{data}}">
</app-pouchdb-query>
The documents in the database are loaded in data
POST http://localhost:5984/kittens/_find 400 (Bad Request)
Object {error: "bad_request", reason: "Referer header must match host.", status: 400, name: "bad_request", message: "Referer header must match host."}
app-pouchdb-query
element as defined above in the page.I am trying to save a list of products to the local database, coming from my server in the form of a json array using the app-pouchdb element.
What I need is to create a document for each product so I can query the local database later, using the document _id, but as I see the element asks for a doc-id (ie.: parsip) right at the start:
<app-pouchdb-document
db-name="cats"
doc-id="parsnip"
data="{{cat}}">
</app-pouchdb-document>
Using the same _id, rows are overwritten and I end up with only one document in the end. I have read the docs a few times, but I can't find any hint on achieving separate document for each product from my array.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.