Comments (6)
I forgot to check the method fromInstance
. Probably it will work.
from nedb-promise.
@DREZZ3R fromInstance
will probably work. However, at the top of index.js
, I have the line require('nedb')
, so this will probably require a bit of refactoring to fully support the browser. I can probably accomplish this with the following steps:
- Split
fromInstance
into its own file - Create
browser.js
that requiresnedb/browser-version/out/nedb.min.js
and then usesfromInstance
to promisify that - Create a WebPack config to bundle all of this together
It would also be good to add some tests that run in the browser, using Karma, or something like that. Perhaps I'll take the opportunity to also convert this repo to TypeScript
from nedb-promise.
@jrop I've tried using the browser version, but it just does not work. I tested with this code:
import Nedb from 'nedb/browser-version/out/nedb.min.js';
import nedbPromify from 'nedb-promise';
let db = nedbPromify.fromInstance(new Nedb('images', {autoload: true}))
db.findOne({})
.then(("findOne RES", res) => console.log(res))
.catch(("findOne ERR", err) => console.log(err))
This does not give any error, it just stops. If I use this in an async
function everything after the query, is not executed.
from nedb-promise.
@DREZZ3R That does not seem to be valid syntax:
.then(("findOne RES", res) => console.log(res))
// Should be?: .then((res) => console.log("findOne RES", res))
.catch(("findOne ERR", err) => console.log(err))
// Should be?: .catch((err) => console.log("findOne ERR", err))
It seems that the only parsers that accept that syntax are Flow and TypeScript, and even then, they see that as a parenthesized comma-expression, with a second argument of console.log(...)
. I bet if you changed to the syntax proposed above the callbacks might get executed
from nedb-promise.
@jrop I figured it out. Yes, the syntax I wrote here is wrong, but in the app's source code was right and didn't work.
The problem was how I created the Nedb instance.
How it was:
let db = nedbPromify.fromInstance(new Nedb('images', {autoload: true}))
How it should've been:
let db = nedbPromify.fromInstance(new Nedb({filename: "images", autoload: true}))
I thought the first argument was the DB name and then options as second. Nedb only accepts one argument either a string or a object with options. I feel stupid, thank you for your patience.
from nedb-promise.
@DREZZ3R Awesome, glad it's solved! I do eventually want to convert this to TypeScript so that errors such as this are easier to spot; I just have to find time lol
from nedb-promise.
Related Issues (12)
- Planning to use this HOT 11
- .limit(10) not working HOT 1
- Promise swallowing error from datastoreInstance.find() HOT 1
- Maximum call stack size exceeded at BinarySearchTree.compareThings HOT 7
- Bump major version for non-backwards compatible api changes HOT 2
- Need delete HOT 6
- cannot update twice HOT 1
- Update NeDB HOT 2
- Datastore.persistence is undefined. HOT 3
- TypeError: Cannot read property 'setAutocompactionInterval' of undefined HOT 1
- .count() ends process HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nedb-promise.