{"action":"opened","issue":{"url":"https://api.github.com/repos/louischatriot/nedb/issues/417","repository_url":"https://api.github.com/repos/louischatriot/nedb","labels_url":"https://api.github.com/repos/louischatriot/nedb/issues/417/labels{/name}","comments_url":"https://api.github.com/repos/louischatriot/nedb/issues/417/comments","events_url":"https://api.github.com/repos/louischatriot/nedb/issues/417/events","html_url":"https://github.com/louischatriot/nedb/issues/417","id":154221867,"number":417,"title":"Bootstrap","user":{"login":"xduseko","id":9591957,"avatar_url":"https://avatars.githubusercontent.com/u/9591957?v=3","gravatar_id":"","url":"https://api.github.com/users/xduseko","html_url":"https://github.com/xduseko","followers_url":"https://api.github.com/users/xduseko/followers","following_url":"https://api.github.com/users/xduseko/following{/other_user}","gists_url":"https://api.github.com/users/xduseko/gists{/gist_id}","starred_url":"https://api.github.com/users/xduseko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xduseko/subscriptions","organizations_url":"https://api.github.com/users/xduseko/orgs","repos_url":"https://api.github.com/users/xduseko/repos","events_url":"https://api.github.com/users/xduseko/events{/privacy}","received_events_url":"https://api.github.com/users/xduseko/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-11T11:35:29Z","updated_at":"2016-05-11T11:35:29Z","closed_at":null,"body":"Autoload feature defers all async operations until database file is completely read and ready. It there a way to defer those even more until given promise is resolved?\r\nI have \"bootstrap\" script that checks if database is empty and then inserts some documents. I want to defer all other operations until it is done.\r\n\r\nstep 1\r\n```\r\nrm documents.nedb\r\n```\r\n\r\nstep 2\r\n```javascript\r\nvar db = new nedb({filename: 'documents.nedb', autoload: true});\r\ndb.count({}, function (err, count) {\r\n  if (count === 0) {\r\n    db.insert([{value: 1}, {value: 2}, {value: 3}]);\r\n  }\r\n});\r\n\r\n//...\r\n\r\ndb.find({}, function (err, docs) {\r\n  assert docs.length === 3;\r\n});\r\n\r\n```\r\n\r\nI know I can create promise and chain all database operations, but that would be annoying. I would like to achieve it in \"autoload\" way."}}