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

Why is data lost at electron? #8842

Open
codepandy opened this issue Dec 28, 2023 · 0 comments
Open

Why is data lost at electron? #8842

codepandy opened this issue Dec 28, 2023 · 0 comments

Comments

@codepandy
Copy link

After react runs the restart program in electron, the cached data in electron is lost, and the web page is not lost。


const db = new PouchDB("testdb");
  const onCeateDB = () => {
    const todo = {
      _id: new Date().toISOString(),
      title: `这是一条数据${Date.now()}`,
      completed: false,
    };
    db.put(todo, function callback(err, result) {
      if (!err) {
        console.log("Successfully posted a todo!", result);
      }
    });
  };

  const onGetData = () => {
    db.allDocs({ include_docs: true, descending: true }, function (err, doc) {
      console.log(doc.rows);
    });
  };


<button onClick={onCeateDB}>创建数据库</button>
      <button onClick={onGetData}>获取数据库</button>
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

1 participant