Method: Wgit::Database::MongoDB#get

Defined in:
lib/wgit/database/adapters/mongo_db.rb

#get(obj) ⇒ Wgit::Url, ...

Returns a record from the database with the matching 'url' field; or nil. Pass either a Wgit::Url or Wgit::Document instance.

Parameters:

  • The record to search the DB for.

Returns:

  • The record with the matching 'url' field or nil if no results can be found.



430
431
432
433
434
435
436
437
# File 'lib/wgit/database/adapters/mongo_db.rb', line 430

def get(obj)
  collection, query = get_model_info(obj)

  record = retrieve(collection, query, limit: 1).first
  return nil unless record

  obj.class.new(record)
end