-
Notifications
You must be signed in to change notification settings - Fork 67
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
why pouchdb.rel.find() works only with integer id? #170
Comments
The ID's Relational Pouch uses contain the model in the PouchDB _id like author_2_NonIntregerID See: https://my.cloudstation.com/bloggr/author_2_01991B5B-653A-723F-A8F4-C80030E10C3B https://github.com/pouchdb-community/relational-pouch#dbrelmakedocidparsedid |
Problem is that i dont have id to makeDocId(). Like in mysql we dont have to give id because it autoincrement id. But in this case i have to give id everytime which i dont have. How to do that . You idea will be appropriated. One idea is to get count of records and increment in it and place that id. But i dont think it should work like that. And relation with auto generated uuid are not working. I am stuck here @broerse |
@bilalswiftsolutions In an eventually consistent database like CouchDB/PouchDB there is no way to know the next number. We use uuid's for recorded ID's and listen with a Node.js or OpenWhisk to db.changes in CouchDB and update order numbers or invoice numbers if they are empty. This way only one process determines the numbers. So if users are offline they can create new Orders or Invoices and when they come online the order numbers and invoice numbers are automatically assigned. We store the next ID's in the database like this: {
"_id":"appconfig_2_referencelist",
"_rev":"6577-f4117ec3b0e8bc0caa1d72a203650ecc",
"data":{
"nextOrderReferencenr":"45080",
"nextInbookReferencenr":"1230054",
"nextDefectivesReferencenr":"1570",
"nextProformainvoicesReferencenr":"3230229",
"since":"544707-g1AAAAJ7eJzLYWBg4MhgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUoxJTIkyf___z8rgzmJgZGpMxcoxm6eapRkammCTQ8ek5IUgGSSPdww1odgwywMjZKM0gxJNcwBZFg8wmX7wIaZWaYZG5hYkmpYAsiwerhhjOpgw9LSjIxNDCxINCyPBUgyNAApoHnzIQaqPAYbaJJqnGJuZECWgQsgBu6HGMjLDjbQMDExydTImCwDD0AMvA8xkCsT4mVDQ2MzA3OyDHwAMRAahuyKEBeampknmmN1YRYAuBTC7Q"
}} |
So if i need to access from agent relation to staff i need to have staff if
in agent and if i want to access agent from staff then i need to have agent
id in staff? It is bidirectional?
I can not access agent from staff while having staff id in agent?
…On Mon, Jun 19, 2023, 1:28 AM Martin Broerse ***@***.***> wrote:
@bilalswiftsolutions <https://github.com/bilalswiftsolutions> In an
eventually consistent database like CouchDB/PouchDB there is no way to know
the next number.
We use uuid's for recorded ID's and listen with a Node.js or OpenWhisk to
db.changes in CouchDB and update order numbers or invoice numbers if they
are empty. This way only one process determines the numbers. So if users
are offline they can create new Orders or Invoices and when they come
online the order numbers and invoice numbers are automatically assigned. We
store the next ID's in the database like this:
{"_id":"appconfig_2_referencelist","_rev":"6577-f4117ec3b0e8bc0caa1d72a203650ecc","data":{
"nextOrderReferencenr":"45080",
"nextInbookReferencenr":"1230054",
"nextDefectivesReferencenr":"1570",
"nextProformainvoicesReferencenr":"3230229",
"since":"544707-g1AAAAJ7eJzLYWBg4MhgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUoxJTIkyf___z8rgzmJgZGpMxcoxm6eapRkammCTQ8ek5IUgGSSPdww1odgwywMjZKM0gxJNcwBZFg8wmX7wIaZWaYZG5hYkmpYAsiwerhhjOpgw9LSjIxNDCxINCyPBUgyNAApoHnzIQaqPAYbaJJqnGJuZECWgQsgBu6HGMjLDjbQMDExydTImCwDD0AMvA8xkCsT4mVDQ2MzA3OyDHwAMRAahuyKEBeampknmmN1YRYAuBTC7Q"
}}
—
Reply to this email directly, view it on GitHub
<#170 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANXTZUOWDOVTMYU67G62RX3XL5QGBANCNFSM6AAAAAAZK3CNQI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@bilalswiftsolutions I don't completely follow. Maybe take a look at the data from https://bloggr.exmer.com/ https://my.cloudstation.com/bloggr/post_2_C7F645EA-12FA-4744-8CC5-698945C3C6D1 |
@bilalswiftsolutions Not in the readme I see but db.rel.uuid(); is public if you need a new ID. let id = data.id;
if (!id) {
id = data.id = rel.uuid();
} See how it is done for EmberData createRecord : https://github.com/pouchdb-community/ember-pouch/blob/master/addon/adapters/pouch.js#L520 |
I am trying to fetch related record with the help of pouchdb.rel.find('') it works fine when i give integer id it fetch the related data, but i don't give integer id while storing and give same id generated by couch db it is not working then
this will work
but this will not work
As i can not give id manually every time, maybe i am missing some please guide me about it what i am doing wrong here
this is full file i am working on
The text was updated successfully, but these errors were encountered: