       )
       resolve(p)
 
+  # db server safe. will get db server itself
   delete_note: (guid) =>
     console.log('delete_note(' + guid + ') invoked')
     return @find_note_by_guid(guid).then(
       (note) =>
-        alert('!!')
         if note is null
           console.log('cannot delete note null, aborted')
         else
           console.log('about to remove note id ' + note.id)
-          @db_server.notes.remove(note.id)
+          p = dbProvider.get_db_server_promise().then (server) =>
+            server.notes.remove(note.id)
+          p.catch (error) =>
+            alert('delete_note(' + guid + ') failed')
           console.log('local note ' + note.guid + ' deleted. id: ' + note.id)
-      ,(error) =>
+      (error) =>
         alert('error!')
     )
 
   # fixme for debug
   add_fake_note: () =>
-    @db_server.notes.add({
-      guid: '9999-9999-9999-9999'
-      title: 'fake title'
-      status: @NOTE_STATUS.SYNCED_META
-    }).then () ->
-      alert('fake note added to db')
+    dbProvider.get_db_server_promise().then (server) =>
+      server.notes.add({
+        guid: '9999-9999-9999-9999'
+        title: 'fake title'
+        status: @NOTE_STATUS.SYNCED_META
+      }).then () ->
+        alert('fake note added to db')
 
   # ------------------------------------------------------------
   # Return a copy of a note in db with a given guid
   #
-  # db_server safe. will get db_server itself
+  # db server safe. will get db server itself
   # return: promise containing the note's info,
   #         or null if note does not exist
   # ------------------------------------------------------------


  # ------------------------------------------------------------
  # Clear db
  # return: promise
  # ------------------------------------------------------------
  clear_all_notes: () ->
    return new Promise (resolve, reject) =>
      resolve(@db_server.notes.clear())

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

        _note_modify.md = note.md
      if note.status?
        _note_modify.status = note.status
      _modify_p = dbProvider.get_db_server_promise().then (server) =>
          return server.notes.query().filter('guid', note.guid).modify(_note_modify).execute()
      resolve(_modify_p)
    return p.then(
      () =>
        console.log('update note ' + note.guid + ' successfully')
