{"action":"created","issue":{"url":"https://api.github.com/repos/techfort/LokiJS/issues/108","labels_url":"https://api.github.com/repos/techfort/LokiJS/issues/108/labels{/name}","comments_url":"https://api.github.com/repos/techfort/LokiJS/issues/108/comments","events_url":"https://api.github.com/repos/techfort/LokiJS/issues/108/events","html_url":"https://github.com/techfort/LokiJS/issues/108","id":63165026,"number":108,"title":"how to use loaded db outside of callback functions","user":{"login":"tommyhtc","id":4024432,"avatar_url":"https://avatars.githubusercontent.com/u/4024432?v=3","gravatar_id":"","url":"https://api.github.com/users/tommyhtc","html_url":"https://github.com/tommyhtc","followers_url":"https://api.github.com/users/tommyhtc/followers","following_url":"https://api.github.com/users/tommyhtc/following{/other_user}","gists_url":"https://api.github.com/users/tommyhtc/gists{/gist_id}","starred_url":"https://api.github.com/users/tommyhtc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommyhtc/subscriptions","organizations_url":"https://api.github.com/users/tommyhtc/orgs","repos_url":"https://api.github.com/users/tommyhtc/repos","events_url":"https://api.github.com/users/tommyhtc/events{/privacy}","received_events_url":"https://api.github.com/users/tommyhtc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-03-20T05:21:28Z","updated_at":"2015-03-20T22:19:43Z","closed_at":null,"body":"hi there, so I'm just learning loki,\r\n\r\nlet's say I have a loki database called \"test.json\" with a collection \"Users\".\r\nI'm running node,\r\nIn some .js file, I want to access that database and write to it.\r\n\r\nCurrently, I only know how to access a loaded database with callbacks,\r\nfor example, with:\r\n\r\ndb = new loki('test.json',{autoload:true, autocallback: foo()});\r\n\r\nand then I'm able to access the loaded db in foo(), where I can insert stuff or get stuff, etc.\r\n\r\nHowever, is there a way to access the loaded database outside of the callback, or without using callback??\r\n\r\nfor example,\r\nfoo(){\r\n   db = new loki('test.json',{autoload:true}\r\n   somefield = db.getCollection(\"Users\").get(1);\r\n}\r\n\r\nis this possible??\r\nI've tried loadDatabase but it also requires a callback..\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/techfort/LokiJS/issues/comments/84168554","html_url":"https://github.com/techfort/LokiJS/issues/108#issuecomment-84168554","issue_url":"https://api.github.com/repos/techfort/LokiJS/issues/108","id":84168554,"user":{"login":"obeliskos","id":7353046,"avatar_url":"https://avatars.githubusercontent.com/u/7353046?v=3","gravatar_id":"","url":"https://api.github.com/users/obeliskos","html_url":"https://github.com/obeliskos","followers_url":"https://api.github.com/users/obeliskos/followers","following_url":"https://api.github.com/users/obeliskos/following{/other_user}","gists_url":"https://api.github.com/users/obeliskos/gists{/gist_id}","starred_url":"https://api.github.com/users/obeliskos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obeliskos/subscriptions","organizations_url":"https://api.github.com/users/obeliskos/orgs","repos_url":"https://api.github.com/users/obeliskos/repos","events_url":"https://api.github.com/users/obeliskos/events{/privacy}","received_events_url":"https://api.github.com/users/obeliskos/received_events","type":"User","site_admin":false},"created_at":"2015-03-20T22:19:43Z","updated_at":"2015-03-20T22:19:43Z","body":"Glad to help, good luck"}}