Closed ralyodio closed 7 years ago
I think you forgot the polyfills
require("babel-polyfill");
Do I need that? I only want to use native node v7 not babel.
If I add that I get a different error:
Error: Adapter websql not added.
Use RxDB.plugin(require('pouchdb-adapter-websql');
its installed. :|
You are right. I will inspect.
Btw Websql does not work in nodejs. You need another adapter here
I'm new, just following the getting started. What adapter should I use with node.js?
I like the example I posted, with a jsonschema and an object. But I'm not sure what I should be using if not websql.
I think we need a node.js example: https://github.com/pubkey/rxdb/tree/master/examples
I'm confused. Does this library not work with node.js?
Yes, this lib works with nodejs. All tests run in nodejs and the browsers :) Yes we need a nodejs example. To play around I recommend the memory-adapter. For persistent storage use the leveldb-adapter.
leveldown = require('leveldown'); leveldb = require('pouchdb-adapter-leveldb'); RxDB.plugin(leveldb);
@chovy I inspected the issue. I'm sorry, but for some reason you need the babel-polyfill
at the moment, the build does not include the runtime-regenerators.
Here is a working example with rxdb and leveldown.
npm i rxdb rxjs babel-polyfill pouchdb-adapter-leveldb leveldown --save
require('babel-polyfill');
const RxDB = require('rxdb');
RxDB.plugin(require('pouchdb-adapter-leveldb'));
const leveldown = require('leveldown');
async function createDb() {
const db = await RxDB.create({
name: './testdb',
adapter: leveldown, // leveldb-adapters must be passed directly instead of the name
password: 'asdfasdf', // optional
multiInstance: true // default: true
});
const mySchema = {
disableKeyCompression: true,
version: 0,
title: 'things schema',
type: 'object',
properties: {
title: {
type: 'string'
},
link: {
type: 'string'
},
date: {
type: 'date'
}
},
required: ['title', 'link']
};
await db.collection({
name: 'things',
schema: mySchema
}); // create collection
console.dir(db.things);
return;
}
async function run(){
await createDb();
}
run();
I have a pouchdb server, can I point to that? When I run this example code it seems to create its own database in the current directory.
I get an error when running this:
ReferenceError: regeneratorRuntime is not defined
I'm using node v7.7