Access to Profoundjs Instance From a Class

Use this board to ask questions or have discussions with other Profound.js users.
diego.palumbo
New User
Posts: 4
Joined: Mon Nov 25, 2019 11:43 am
First Name: Diego
Last Name: Palumbo
Company Name: iVolution
Contact:

Access to Profoundjs Instance From a Class

Post by diego.palumbo »

Hello everyone!
my objective is to use pjs instance inside a javascript Class but I have some problems.


First of all I tried to call pjs.query() inside a module with a Function and following code works:

- modules/myApp/testFunc.js

Code: Select all

function Test() {
	this.queryC = function() {
		console.log('query...');
		let test = pjs.query('select * from sysibm/sysdummy1');
		console.log('queryC', test);
		return test;
	}
}

exports.TestFunc = Test;

-> modules/myApp/test.js

Code: Select all

function test() {
	var TestF = pjs.require("myapp/testFunc").TestFunc;
	var instanceF = new TestF();
	console.log('instanceF', instanceF);
	instanceF.queryC();
}

exports.run = test;
then I run http://localhost:8082/test and i see in console log :

Code: Select all

instanceF Test { queryC: [Function] }
query...
queryC [ { ibmreqd: 'Y' } ]
Second I tried to put same code inside a Class :

- modules/myApp/testClass.js

Code: Select all


class Test {
	constructor() {
		console.log('costructor...');
	}
	queryC() {
		console.log('query...');  
		return pjs.query('select * from sysibm/sysdummy1');
	}
}

exports.TestClass = Test;

-> modules/myApp/test.js

Code: Select all


function test() {

	var Test = pjs.require("myapp/testClass").TestClass;
	var instance = new Test();
	console.log('instance', instance);
	instance.queryC();

}

exports.run = test;

I get floowing result:

Code: Select all

costructor...
instance Test {}
query...
2019-11-25 16:59:58 | Session 89D97A5694117DAA3250F4512948AA1D4719A4C4BF0010EF33D2F5477F847506
TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
    at Test.queryC (C:\Users\diego\code\profoundjs\modules\myapp\testClass.js:12:35)
    at Object.test (C:\Users\diego\code\profoundjs\modules\myapp\test.js:13:11)
    at Object.profound.call (C:\Users\diego\code\profoundjs\node_modules\profoundjs\api\call.jse:140:25)
    at C:\Users\diego\code\profoundjs\node_modules\profoundjs\server\controller.jse:188:25
I'm not able to access pjs instance anymore inside a class method.

Do you have any advise?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Access to Profoundjs Instance From a Class

Post by Scott Klement »

My guess is that this is something that hasn't been added to Profound.js yet. Please contact our support department so that we can consider whether this is a bug or a new feature that should be added.

Contact Support at support@profoundlogic.com
diego.palumbo
New User
Posts: 4
Joined: Mon Nov 25, 2019 11:43 am
First Name: Diego
Last Name: Palumbo
Company Name: iVolution
Contact:

Re: Access to Profoundjs Instance From a Class

Post by diego.palumbo »

Thank you for your answer.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests