Method: WeaviateRecord::Base.find
- Defined in:
- lib/weaviate_record/base.rb
.find(id) ⇒ Object
Takes an uuid and returns the record with that uuid. If the record is not found, it raises a RecordNotFoundError.
Example:
Article.find('f3b1b3b1-0b3b-4b3b-8b3b-0b3b3b3b3b3b')
#<Article:0x0000000105468ab0 id: "8280210b-9372-4e70-a045-beb7c12a9a24" ...>
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/weaviate_record/base.rb', line 41 def find(id) result = connection.find_call(id) if result.is_a?(Hash) && result['id'] new(_additional: (result), **result['properties']) elsif result == '' raise WeaviateRecord::Errors::RecordNotFoundError, "Couldn't find record with id=#{id}" else raise WeaviateRecord::Errors::ServerError, result['message'] end end |