GithubHelp home page GithubHelp logo

Comments (2)

anatoliychakkaev avatar anatoliychakkaev commented on August 18, 2024

This error may happen when User is not defined correctly before calling
Domain.belongsTo. What if move relationships defenitions to proper place?
(I mead app/models/ dir)

BTW, model names should start with upper case letter.

On Sat, Apr 7, 2012 at 10:15 AM, laoshanlung <
[email protected]

wrote:

I have this schema definition

var Domain = schema.define('domain', {
 name: Number
});

var User = schema.define('user', {
 email: String
});

Domain.belongsTo(User, {as: 'user', foreignKey : 'user_id'});
User.hasMany(Domain, {as : 'domains', foreignKey: 'user_id'});

Then I created some domains and add them to a particular user. I have
checked the database and everything is ok.

Then, I do

domain.user(); // It can get the user id

However if I do something like this

domain.user(function(error, user){
 // user should be a user record ?
});

I got this error

TypeError: Object #<Object> has no method 'find'
   at Object.domain
(/home/vagrant/lib/node_modules/jugglingdb/lib/abstract-class.js:690:22)
   at ModelConstructor.domain
(/home/vagrant/lib/node_modules/jugglingdb/lib/abstract-class.js:705:40)

I am using postgresql 9.1 on Ubuntu 11.10.


Reply to this email directly or view it on GitHub:
#57

Cheers,
Anatoliy Chakkaev
web-developer [js, rails, php]
+7.917.857.858.4

from jugglingdb.

tanqhnguyen avatar tanqhnguyen commented on August 18, 2024

Yes, I have just figured it out. I define models in separated files, which cause errors when models are related to each other. I have moved the relationship definition to a different file and call that file after all models are defined. It works now.

from jugglingdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.