Welcome Guest, Not a member yet? Register   Sign In
Delete from MongoDB using MongoDB Librar
#1

[eluser]sweetD[/eluser]
Hey guys,

I'm using the following mongoDB library but I can't seem to be able to figure out how to delete a document from the collection;

https://github.com/alexbilbie/codeignite...ry/tree/v2

I have tried;

Code:
$id = new MongId($id);

$this->mongo_db
->where(array('_id' => $id))
->delete('lists');

and;

Code:
$id = new MongId($id);
$this->mongo_db->delete($id);

I just keep getting a 500 error.
#2

[eluser]sweetD[/eluser]
This is the function from the library to delete, I don't get what I am not doing correctly.

Code:
public function delete($collection = '')
{
  if (empty($collection))
  {
   $this->_show_error('No Mongo collection selected to delete from', 500);
  }
  
  try
  {
   $this->_dbhandle->{$collection}->remove($this->wheres, array($this->_query_safety => TRUE, 'justOne' => TRUE));
   $this->_clear($collection, 'delete');
   return TRUE;
  }
  
  catch (MongoCursorException $exception)
  {
   $this->_show_error('Delete of data into MongoDB failed: ' . $exception->getMessage(), 500);
  }
}




Theme © iAndrew 2016 - Forum software by © MyBB