You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
In our company we are trying to migrate few applications from java to node js .
As part of the ORM we choose to use node -persist seeing lot of valuable features and it will go long way...
after doing the relational one to many and many to many mapping we found result is not retrieving properly from database.
we created tables in database
CREATE TABLE Person
(
ID int NOT NULL,
NAME varchar2(1000) ,
PHONE_ID int NOT NULL,
PRIMARY KEY (PHONE_ID)
);
CREATE TABLE Phone
(
ID int NOT NULL PRIMARY KEY,
PHONE_ID int NOT NULL,
PHONE_NUMBER int NOT NULL,
CONSTRAINT PHONE_ID FOREIGN KEY (PHONE_ID)
REFERENCES Person(PHONE_ID)
);
Hi ,
Kindly reply to our issue when you have some time, we have couple of developers waiting for your reply :-( .The many to many mapping is very important to us to choose persist as our ORM for multiple applications.
Hi,
In our company we are trying to migrate few applications from java to node js .
As part of the ORM we choose to use node -persist seeing lot of valuable features and it will go long way...
after doing the relational one to many and many to many mapping we found result is not retrieving properly from database.
we created tables in database
CREATE TABLE Person
(
ID int NOT NULL,
NAME varchar2(1000) ,
PHONE_ID int NOT NULL,
PRIMARY KEY (PHONE_ID)
);
CREATE TABLE Phone
(
ID int NOT NULL PRIMARY KEY,
PHONE_ID int NOT NULL,
PHONE_NUMBER int NOT NULL,
CONSTRAINT PHONE_ID FOREIGN KEY (PHONE_ID)
REFERENCES Person(PHONE_ID)
);
node js code
var persist = require('persist');
var type = persist.type;
Phone = persist.define("Phone", {
"id": {
type: type.INTEGER, dbColumnName: 'ID',primaryKey:'ID'
},"PHONE_ID": {
type: type.INTEGER, dbColumnName: 'PHONE_ID'
},"phone_number": {
type: type.INTEGER, dbColumnName: 'PHONE_NUMBER'
}
}, {
"tableName": "PHONE"
});
Person = persist.define("Person", {
"id": {
type: type.INTEGER, dbColumnName: 'ID'
},
"name": {
"type": type.STRING, dbColumnName: 'NAME'
},"PHONE_ID": {
type: type.INTEGER, dbColumnName: 'PHONE_ID',primaryKey:'PHONE_ID'
}
}, {
"tableName": "PERSON"
}).hasMany(Phone,{foreignKey:'PHONE_ID'});
persist.connect({
"driver": "oracle",
"name": "xxxxxx",
"hostname": "xxxxxxxxx",
"user": "ecee_int",
"password": "xxxxxx",
"port": "1521",
"database": "xxxxx",
"pooling": {
"name": "xxxxxxx",
"max": 2,
"min": 1,
"idleTimeoutMillis": 30000
}
}, function(err, connection) {
Person.using(connection).all(function(err, person) {
person.phones.orderBy('number').all(function(err, phones) {
console.log(JSON.stringify(phones));
});
});
});
but the result returned is [{"phones":{},"id":1,"name":"karthik"},{"phones":{},"id":2,"name":"asuthos"},{"phones":{},"id":3,"name":"peter"}]
which don't have associated phones
kindly suggest us what is wrong here ?
thanks
Elcina
The text was updated successfully, but these errors were encountered: