简体   繁体   中英

Can PouchDB be used in Node REPL?

I've tried instantiating a PouchDB instance in node REPL.

In REPL:

var pouchdb = require("pouchdb");
var foo = new pouchdb("foo");

This always causes node to exit with the exception:

undefined:0
TypeError: undefined is not a function.

Can PouchDB be used in Node REPL?

it is literally just the basic repl that doesn't work, starting a custom repl works fine for some unknown reason so running node --eval "require('repl').start('> ');" works

From a current pouchdb clone

~/src/pouchdb (master)$ npm run shell

> pouchdb@2.0.2-alpha shell /Users/daleharvey/src/pouchdb
> ./bin/repl.js

> var foo = new PouchDB('foo');
undefined
> foo.post({'a':'doc'});
[object Object]
>
==> leveldb foo bulkDocs
args: [{"docs":[{"a":"doc"}]},{},null]
result: [
  {
    "ok": true,
    "id": "3C8264BA-8966-4059-9FA2-401E464E54E8",
    "rev": "1-49e9d0c368f1114e0a0b67cdc808d6da"
  }
]
===
>
==> leveldb foo post
args: [{"a":"doc"}]
result: {
  "ok": true,
  "id": "3C8264BA-8966-4059-9FA2-401E464E54E8",
  "rev": "1-49e9d0c368f1114e0a0b67cdc808d6da"
}
===
>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM