Note that there are some explanatory texts on larger screens.

plurals
  1. POBreezejs: Perform search on field in related table
    primarykey
    data
    text
    <p>I have followed tutorials / videos showing off how to perform a live search on data coming from two entities on the northwind database running on a Microsoft backend. </p> <p>I have to develop an application that has a <code>php / mysql</code> backend so have got hold of the php producer classes to do this. I have connected to a Wordpress DB and it all seems to be working well. </p> <p>However, my problem is when I try to perform a search on a related table. I have a grid showing author's <code>displayName</code> (from the User entity), the <code>post title</code> and <code>date</code> (from Posts).</p> <pre class="lang-cs prettyprint-override"><code>&lt;input type="text" data-ng-model="searchText"/&gt; {{searchText}} &lt;table class="table table-hover"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Author &lt;/th&gt; &lt;th&gt;Date&lt;/th&gt; &lt;th&gt;Title&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tr ng-repeat="post in posts"&gt; &lt;td&gt;{{post.user.displayName}}&lt;/td&gt; &lt;td&gt;{{post.date}}&lt;/td&gt; &lt;td&gt;{{post.title}}&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>In the controller (actually the datacontext.js) I have the following to get the data from the server:</p> <pre class="lang-cs prettyprint-override"><code> if (searchText &amp;&amp; (searchText = searchText.trim())) { log("searching for " + searchText); var pred = breeze.Predicate .create('title', 'contains', searchText); query = query.where(pred); } else { console.log("getting all"); } return manager.executeQuery(query).then(success); </code></pre> <p>My problem is with referring to fields in the Predicate correctly. When I run the code searching for just the Posts title Entity as below it works fine.</p> <pre class="lang-cs prettyprint-override"><code>var pred = breeze.Predicate .create('title', 'contains', searchText); </code></pre> <p>As soon as I change it to the following it stops working. There are no errors in the console as well.</p> <pre class="lang-cs prettyprint-override"><code> var pred = breeze.Predicate .create('title', 'contains', searchText) .or('displayname', 'contains', searchText); </code></pre> <p>I have tried several variants of 'displayName' such as 'displayname', 'posts.user.displayname', 'user.displayname' and all those in camelCase as well.</p> <p>Can someone tell me where I am going wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload