-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Issue initialising rxdb with seed data #5885
Comments
I think you are using it correctly and you found a bug. Please make a PR with a test case to reproduce the problem. |
Found a work around for now! The idea is to initialize the collection only if database creation on the couchdb instance passes. If it fails, that would mean the database was already created and already initialize. console.log('DatabaseService: sync');
await Promise.all(
Object.values(db.collections).map(async (col) => {
try {
// create the CouchDB database
await fetch(
syncURL + col.name + '/',
{
method: 'PUT'
}
).then(response => {
if (!response.ok) {
throw new Error(`Failed to create database: ${response.status}`);
}
});
// Init contribution graphs
if (col.name === 'contribution_graph') {
const graphCollection = db.contribution_graph;
const graphDocuments = await graphCollection.find().exec();
if (graphDocuments.length == 0) {
await graphCollection.bulkInsert([
{ index: 1, activity: 'Study', streaks: [] },
{ index: 2, activity: 'Gym', streaks: [] },
]);
};
}
} catch (err) { }
})
); |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed soon. If you still have a problem, make a PR with a test case or to prove that you have tried to fix the problem. Notice that only bugs in the rxdb premium plugins are ensured to be fixed by the maintainer. Everything else is expected to be fixed by the community, likely you must fix it by yourself. |
Issues are autoclosed after some time. If you still have a problem, make a PR with a test case or to prove that you have tried to fix the problem. |
I am trying to initialise the rxdb database with a seed data if not already found in the database.
Create Database
This is pretty much straight out of documentation besides initialising the database with seed data.
Problem Statement
When I try to start the app fresh i.e., when there is no collection in the database it all works just fine. The documents are created in the local storage and then replicated to the pouch db server. But it becomes issue if there are collections/documents already in the pouchdb server.
Steps To Reproduce
The issue seems to be that rxdb local storage is getting initialised before it is synced with the pouchdb server!
How do we initialise the db instance?? Please suggest!
The text was updated successfully, but these errors were encountered: