Using hanami ORM to do autocomplete - ruby

I am trying to implement autocomplete with hanami-model and I am trying to find in documentation or google how fetch records using LIKE function.
I am trying to reflect following SQL query using hanami repositories:
SELECT * FROM users WHERE name LIKE '%a'
Do you know how to do this? Thanks for all answers.

Pavel is right, you can use repo.where { name.like(pattern) } code for work with LIKE/ILIKE.
Here you can find real example :)

Related

Subquery in JQuery QueryBuilder

I am going to use the JQuery Query Builder plugin in my project. I want to know how query will generate for relational table.
For example, I have two tables user and user_emails. I want to filter those users which have an email address. To get this result, I have to use subquery on user_emails table. Has that been possible by using this plugin? In the demo, I have not found this case.
Your question is vague. Do you want to build conditions in the jQuery-QueryBuilder for "All users with emails"? You also want the jQuery-QueryBuilder to look and return something like the following?
After you clarify the community can point you in the right direction.

How implement join queries in parse.com javascript?

I am new on parse server ( parse.com ). I have two classes "students_records" and "students_fee". I am storing fee records in class "students_fee" with objectId of "students_records" in column "student_id". Now I want to collect records from both classes by one query similar to join query we do in mysql with base on column 'fee_year' in class "students_fee". for example get all students who have 'fee_year'=2016 and 'student_id'=objectId of "students_records", this is link https://parseplatform.github.io/docs/js/guide/ of guide I am currently getting help, but i can't find such thing. Can anyone tell me how to do that?
Thanks.
Since parse use MongoDB (NoSQL) behind the scenes there is no real "join". What you can do is to create a array relationship from students to records and then use include in your query in order to include all the records under a student.
You can read more about it here.
I recommend you to use Parse SDK's here in order to keep it simple.
the Parse SDK is available for all the popular programming languages (e.g. iOS, Android, PHP, JavaScript and more)

Linq security - hide columns

I am struggling a bit on what probably is a simple matter or something I misunderstand... But anyway, using Linq entity code first, I am trying to keep some of my tables to be inaccessible from the client, without success.
Using Breeze, I have made a datacontext that holds only the dbsets I want exposed, fine.
But when I write a query using .expand(). For example, let's say I have a posts table which I want to expose, and an Owner table that I want to hide.
Using a query like:
var query = EntityQuery
.from('Posts')
.expand('Owner');
I can still see all the columns from Owner.
So the question is: in Linq, how am I supposed to secure/protect/hide the tables, and/or specific columns, that I want to hide?
After some digging, all I have found is the [JsonIgnore] attribute, which seems insufficient to me.
What is the best way to do this? I feel I am missing something probably huge here, but it's the end of the day around here...
Thanks
If you are using the Breeze's WebApi implementation then Breeze also supports ODataQueryOptions ( see here and here ).
This allows you to mark up your controller methods so as to limit how the query is interpreted. For example, to only allow filtering on your 'Posts' query and therefore exclude the ability to "expand" or "select" 'Owners' from any 'Posts' request you could do the following.
[Queryable(AllowedQueryOptions=AllowedQueryOptions.Filter| AllowedQueryOptions.Top | AllowQueryOptions.Skip)]
public IQueryable<Posts> Posts() {
....
}
Ok apparently my question was already addressed here:
Risks of using OData and IQueryable
I just found it.

Find or create (upsert) functionality in Doctrine 2

Does Doctrine 2 have upsert functionality built in? It doesn't seem to, but I wasn't able to find a definitive yes-or-no answer.
If it does, I would of course be interested to see an example and/or some documentation.
I believe I found the answer. As of today (10/15/2012), there's an open "add upsert support" issue for Doctrine. I assume that this ticket wouldn't still be open if Doctrine 2 did have upsert support, so I guess there's my definitive answer.
Upsert is already present in Doctrine.
Using the query builder, you have to set findAndUpdate() and returnNew() if you want to return the document. Set upsert() and you're ready to go.
For example:
$documentMannager->createQueryBuilder('App\Domain')
->findAndUpdate()
->returnNew()
->field('_id')->equals($id)
->field('page')->equals($page)
->field('count')->inc(1)
->upsert()
->getQuery()
->execute();
This is the way i implement a bucket pattern.

Rand() in TYPO3 Extbase Query

I'm using Extbase in TYPO3.
I want to create some repository function which can get a random record from the database.
Is there a way to resolve this with the Extbase Query Language?
Look at this issue:
http://forge.typo3.org/issues/14026
Seems like this is still a problem in Extbase.
But there is some workarounds like this one:
http://typo3blogger.de/random-record-repository/

Resources