Vuejs 使用 NeDB,找不到数据库文件

Vuejs use NeDB,can not find database files

Vue创建项目:

vue init webpack-simple nedbtest

安装Nedb数据库:

npm i nedb -S

App.vue

<template>
<div>
  <button @click="insert">insertData</button>
  <button @click="find">FindData</button>
</div>
</template>

<script>
  var Datastore = require('nedb')
  var db = new Datastore({filename:'./test.db', autoload:true})
  export default {
    name: 'app',
    methods:{
      insert () {
        db.insert({name:"admin", password:"123"}, function(err, res) {
          console.log(res)
        })
      },
      find () {
        db.find({}, function(err, res) {
          console.log(res)
        })
      },
    }
  }
</script>

test.db文件在哪里?找不到这个文件!我用Nodejs可以找到这个文件。

如文档中 here 所述:

In the browser version, If you specify a filename, the database will be persistent, and automatically select the best storage method available (IndexedDB, WebSQL or localStorage) depending on the browser.

这意味着 "filename" 必须存储在任一此方法中的某处,具体取决于浏览器。

我从未使用过这个项目,但我想它必须将文件名提供给 indexDB 中的数据库,或者提供给 localStorage 值的键等...

README 中解释说,在浏览器版本中,数据库被保存到浏览器中可用的最佳存储选项,其中包括 indexedDB、localstorage 等。

您在硬盘上找不到这个文件,因为浏览器时代不允许脚本创建文件。