Skip to content
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

Suggestion: model.find with ? and :params #124

Open
limadm opened this issue Jul 12, 2016 · 4 comments
Open

Suggestion: model.find with ? and :params #124

limadm opened this issue Jul 12, 2016 · 4 comments

Comments

@limadm
Copy link

limadm commented Jul 12, 2016

Hello!

First, congratulations for this project! I saw it in a LuaConf this year and it's seems really promising, so I adopted it for developing new applications, so I can work to help it grow fast, stable and friendly.

Now on the issue: I implemented a separate model.query in my fork to be able to do this:

local params = {
  device = Device:query('num_points is not null LIMIT 1'),
  points = {}
}
for p in Point:query {
  '(name like ? OR description like ?) AND size < :size LIMIT 10',
  name, desc,
  size = params.device.size
} do
  table.insert(params.points, p)
end
page:render('view', params)

In the process I saw a comment that model.find* should support and escape parameterized attributes, so I think my implementation suits this task.
But before adopting this change, couldn't we make a more general model query syntax to suit both SQL and NoSQL ORM (e.g. tarantool, a luajit nosql db)? A setup with openresty and tarantool is really challenging to beat, performance-wise. What you think? =]

@Etiene
Copy link
Member

Etiene commented Sep 7, 2016

Sorry for taking long to reply to this issue! I was finishing my master thesis!

There is another issue concerning db queries that was open more recently by @CriztianiX. Maybe we should make a joint effort on refactoring how the db module works for a 1.0 release!

Alternatively, there is a student from India from Rails Girls Summer of Code that was interested in contributing and making a sailor-redis integration. What do you think? We could devise some goals, include tarantool and share the effort :)

I'll have a two month vacation between graduating and starting a job, I really want to get some interesting things done here :D

@CriztianiX
Copy link

#127

@CriztianiX
Copy link

CriztianiX commented Sep 9, 2016

I'm refactoring the db layer (just playing) and you can check it in my brach
I've added a new "interpolate query" function

https://github.com/CriztianiX/sailor/tree/ref_db

@Etiene
Copy link
Member

Etiene commented Sep 14, 2016

Cool! I really like the code you're putting there! Wow, resty-postgres as well! That's awesome! Please don't forget to take a look at these commit message messages guidelines for the next commits: https://github.com/sailorproject/sailor/blob/master/CONTRIBUTING.md#commit-message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants