node-orm2 icon indicating copy to clipboard operation
node-orm2 copied to clipboard

Link table properties included twice

Open ibox4real opened this issue 9 years ago • 1 comments

packages
+------------+---------------+------+-----+---------+----------------+
| Field      | Type          | Null | Key | Default | Extra          |
+------------+---------------+------+-----+---------+----------------+
| id         | int(11)       | NO   | PRI | NULL    | auto_increment |
| name       | varchar(150)  | NO   | UNI | NULL    |                |
| montly_fee | decimal(13,2) | NO   |     | NULL    |                |
| annual_fee | decimal(13,2) | NO   |     | NULL    |                |
+------------+---------------+------+-----+---------+----------------+

services
+-------+--------------+------+-----+---------+----------------+
| Field | Type         | Null | Key | Default | Extra          |
+-------+--------------+------+-----+---------+----------------+
| id    | int(11)      | NO   | PRI | NULL    | auto_increment |
| name  | varchar(250) | NO   | UNI | NULL    |                |
+-------+--------------+------+-----+---------+----------------+

package_services
+------------+-----------------------------+------+-----+---------+----------------+
| Field      | Type                        | Null | Key | Default | Extra          |
+------------+-----------------------------+------+-----+---------+----------------+
| id         | int(11)                     | NO   | PRI | NULL    | auto_increment |
| package_id | int(11)                     | NO   | MUL | NULL    |                |
| service_id | int(11)                     | NO   | MUL | NULL    |                |
| type       | enum('Included','Optional') | NO   |     | NULL    |                |
| fee        | decimal(13,2)               | NO   |     | NULL    |                |
+------------+-----------------------------+------+-----+---------+----------------+

var extra = {
    fee:{
        type:"number"
    },
    type: {
       type: 'enum',
       values: ['Included','Optional'],
       defaultValue: null
    }
};

Packages.hasMany('services',Services,extra,{});

Packages.getServices()

//Returns link table fields twice

[{
    "id":1,
    "name" : "Unlimited downloads"
    "fee":39.99,
    "type":"Optional"
    "extra":{
        "fee":39.99,
        "type":"Optional"
     }
}]

ibox4real avatar Jul 12 '16 13:07 ibox4real

So is this expected behaviour or a bug?

ibox4real avatar Jul 28 '16 09:07 ibox4real