   # ------------------------------------------------------------
   # Add a remote note's metadata which is not in local db to db
   #
+  # db server safe. will get db server itself
   # return: promise
   # ------------------------------------------------------------
   add_note_meta: (note) ->
     console.log('Adding note to db - guid: ' + note.guid + ' title: ' + note.title)
-    return new Promise (resolve, reject) =>
-      resolve(
-        @db_server.notes.add({
-          guid: note.guid
-          title: note.title
-          status: @NOTE_STATUS.SYNCED_META
-        })
-      )
+    return dbProvider.get_db_server_promise().then (server) =>
+      return new Promise (resolve, reject) =>
+        resolve(
+          server.notes.add({
+            guid: note.guid
+            title: note.title
+            status: @NOTE_STATUS.SYNCED_META
+          })
+        )
 
   # ------------------------------------------------------------
   # Update a note
+  #
+  # db server safe. will get db server itself
   # return: promise
   # ------------------------------------------------------------
   update_note: (note) =>

  #                  | load note data from remote
  #                  |
  # synced_meta ------

  constructor: ->
    dbProvider.get_db_server_promise().then (server) =>
      @db_server = server
      console.log('DB initialized from NoteManager')

  NOTE_STATUS:
    NEW: 0


  # ------------------------------------------------------------
  # Clear db
  #
  # db server safe. will get db server itself
  # return: promise
  # ------------------------------------------------------------
  clear_all_notes: () ->
    return dbProvider.get_db_server_promise().then (server) =>
      server.notes.clear()

  # --------------------------------- tmp operations --------------------------------
]
