petersirka / nosql

NoSQL embedded database for small node.js projects
Other
295 stars 48 forks source link

Insert Unique with Where throws error #35

Closed biomade closed 7 years ago

biomade commented 7 years ago

Here is the next issue I tried to insert a second record with the unique flag and I get an error stating that where is not a function

Here is the code and the error output CODE:

var dbNewsletter = db.load('db/newsletter.nosql');
//insert two records
dbNewsletter.insert({name: 'laurie', email: 'laurie@gmail.com'} ) 
dbNewsletter.insert({name: 'erich', email: 'erich@gmail.com'} ) 
console.log("inserted two records");
//insert if they don't exist, do unique
dbNewsletter.insert({name: 'laurie', email: 'laurie@gmail.com'}, true).where('name', 'laurie') 
dbNewsletter.insert({name: 'mary', email: 'mary@gmail.com'}, true).where('name', 'mary')

ERROR OUTPUT:

`starting application
inserted two records
C:\SourceCode\NoSQLTest\index.js:14
dbNewsletter.insert({name: 'laurie', email: 'laurie@gmail.com'}, true).where('name', 'laurie')
                                                                       ^
TypeError: dbNewsletter.insert(...).where is not a function
    at Object.<anonymous> (C:\SourceCode\NoSQLTest\index.js:14:72)
    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
petersirka commented 7 years ago

Shit, there is a bug. I'll update it (tomorrow) about new version from Total.js framework. Sorry and thank you!

biomade commented 7 years ago

I have a habit of finding bugs ;-) (where I work, in c#) Thanks, I look forward to the new release. I will keep working and will probably have more questions along the way since I new to this.

petersirka commented 7 years ago

Fixed. Try to download latest version from NPM: $ npm install nosql. Thank you!

biomade commented 7 years ago

weill do and thanks