petersirka / nosql

NoSQL embedded database for small node.js projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't insert into db

biomade opened this issue · comments

I am hoping to use your NoSQL db in an Electron application. I want to learn how to use it first.
I have a small nodeJS app set up to get started

I am trying to run this, based upon your documentation
const db = require('nosql'); //create db var mydb = db.load('db/mydatabase.nosql'); console.log("created db") mydb('newsletter').insert({name: 'laurie', email: 'laurie@gmail.com'})

I am presented with this error message. I do not understand what to use in place of mydb. Your documentation doesn't have a clear explanation

starting application
created db
C:\SourceCode\NoSQLTest\index.js:10
mydb('newsletter').insert({name: 'laurie', email: 'laurie@gmail.com'})
^

TypeError: mydb is not a function
at Object. (C:\SourceCode\NoSQLTest\index.js:10:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
'

Hi @biomade,
.load() opens DB, example:

var dbNewsletter = db.load('db/newsletter.nosql');
dbNewsletter.insert({ email: '...' });

var dbUsers = db.load('db/users.nosql');
dbUsers.insert({ email: '...' });

Thank you!

Thanks.
Now to figure out how to retrieve data.