obj.selectJSON return data records twice

21 views
Skip to first unread message

Hualong Shen

unread,
Jul 12, 2015, 2:06:10 AM7/12/15
to persis...@googlegroups.com
I use persistencejs in node.js with mysql database.
I define such objects:

var Student = persistence.define('Student', {
  refid
: "TEXT",
  firstName
: "TEXT",
  lastName
: "TEXT"
});

var Table = persistence.define('Table', {
  size
: 'INT',
  location
: 'INT',
  sectionid
: 'TEXT'
});

var Section = persistence.define('Section', {
  refid
: 'TEXT',
  name
: 'TEXT',
  longName
: 'TEXT'
});

Student.hasMany('tables', Table, 'students');
Table.hasMany('students', Student, 'tables');

Section.hasMany('tables', Table, 'section');

Section.hasMany('students', Student, 'sections');
Student.hasMany('sections', Section, 'students');

Student.index(('refid'),{unique:true});
Section.index(('refid'),{unique:true});

And I use the code below to get all students in a section, but the returned data contains each student record twice.
session.transaction(function (tx) {
   
Section.findBy(session, tx, "refid", sectionid, function(result) {
      result
.selectJSON(tx, ['students.refid'], function(data) {
       
//  Her 'data' contains each student record twice.

Did I use findBy or selectJSON method wrong? Can anybody help me? Thanks!!!!
Reply all
Reply to author
Forward
0 new messages