2

I'm trying to use loki.js in a browser app. I included the following script in the HTML

<script src="./bower_components/lokijs/src/lokijs.js"></script>

However the following js code gave me "unexpected token" error

db = new loki('test');
user247702
  • 23,641
  • 15
  • 110
  • 157
user1860288
  • 512
  • 2
  • 6
  • 18
  • 2
    Can you confirm that `lokijs.js` is actually getting loaded by the browser? – phuzi Apr 21 '15 at 08:07
  • check if its loading properly. I can't find any other mistake – Susheel Singh Apr 21 '15 at 08:32
  • Thanks - I wonder what could cause lokijs.js not to load? I inserted this new fragment in working code; used "ls" shell in the same directory to make sure the path is correct. I can't see the source file in Chrome Developers console. – user1860288 Apr 21 '15 at 10:53
  • 1
    Hi, author of LokiJS here. If you create a plunker / jsfiddle i could try and help you out. – Joe Minichino Apr 23 '15 at 19:13

1 Answers1

0

Include the following script in your app

<script src="./bower_components/lokijs/build/lokijs.min.js"></script>

and then in your JavaScript file, or in script tags

    var db = new loki('test.json');
    var children = db.addCollection('children');
    children.insert({name:'Sleipnir', legs: 8});
    console.log(children.get(1)); // returns Sleipnir 
Rizwan Haider
  • 167
  • 2
  • 17