On Sun, Mar 10, 2013 at 3:10 PM, Venkatesh U <[email protected]> wrote:

> Hi,
>   I have defined the following class in a .js file and I am trying to
> create an object of this class, but it is not working. I am getting
> undefined instead of the object, when I use the new. I am new to both
> node.js and JavaScript. It will be great help to me, if somebody can give
> some insights on how to do simple OOP in node.js. Thanks in advance.
>

Did you export DBManager from smailer.js?

--
Martin Cooper


Venki
>
> function DBManager(port, host, dbname) {
> // Retrieve
> var MongoClient = require('mongodb').MongoClient;
>
> // Connect to the db
> MongoClient.connect("mongodb://localhost:" + port + "/" + dbname, function(
> err, db) {
> if (!err) {
> console.log("We are connected");
> this.db = db;
> this.domainStore = this.db.collection('domain', function(err,
> result) {
> if (err) {
> console.log("unable to get domain store " + err);
> }
> });
> this.emailStore = this.db.collection('email',
> function(err, result) {
> if (err) {
> console.log("unable to get email store " + err);
> }
> });
> }
> });
> };
>
>
> I am creating the object by using the below code.
>
> > var z = require('./smailer.js')
> > var k = new z.DBManager(27017, 'localhost', 'dev')
> > k
> {}
>
>
>
>  --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to