-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Model.last method added like in ActiveRecord in Rails framework #100
base: master
Are you sure you want to change the base?
Conversation
@@ -137,6 +138,13 @@ def first | |||
execute.first | |||
end | |||
|
|||
#my contribution | |||
def last | |||
order('created_at desc') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you don't want to order by created_at
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. If this method were to be added it would need to take some kind of option param to allow users to return the last
object sorted by a field they specify
I'd recommend against merging. Ordering by |
Thanks for the PR. I'll take a little more time to review it, but I think @jamonholmgren has a good point. Also, there are some files that need to be checked out of the PR. |
Actually in ActiveRecord, it gives us a function model.last which returns the last row of the table. Keeping that in mind, I have worked on this. |
@@ -108,6 +108,7 @@ def execute | |||
return results.to_i | |||
else | |||
results = JSON.parse(resp)['results'] | |||
puts results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldnt be left here
None of the netbeans project files should be included |
I am going to put this pull request to add a new method Mode.last to get the last row in table just like it is available in Active Record ORM.