S
S
semolex2014-11-27 12:24:53
MongoDB
semolex, 2014-11-27 12:24:53

How to parse an object with nested fields that is returned by MongoEngine (Flask\Backbone\MongoDB bundle)?

Hello!
There is the following problem.
I have object schemas created with MongoEngine:
Users and Items.
In Users there is a ReferenceField items, in which sending to an object from the Items schema is added.
Using Backbone, I need to parse the sent User object, which contains the Items list.
I do it like this:

<% _.each(user.toArray(), function(field, key, list) { %>  
     <tr>
       <td><%- field.get('_id') %></td>
       <td><%- field.get('first_name') %></td>
       <td><%- field.get('last_name') %></td>
            <td><%- field.get('items') %></td>
 <% }) %>
     </tr>


But, in the items field, I have an empty value, although the console.log object has this field:
items: Array[1]0: Object_id: Object$oid: "54638b8089466464ff4d2cf9"


How to access the attributes of this object so that the templater correctly shows them in the template? Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2014-11-27
@nextel

you need to loop through all the values ​​nested in item and display them in the same way as field is displayed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question