Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8630595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:05:44+00:00 2026-06-12T09:05:44+00:00

Using Node.js and a SQL-like database, what are my options when it comes to

  • 0

Using Node.js and a SQL-like database, what are my options when it comes to implementing database inheritance model? I looked around and it seems that due to popularity of noSQL database in Node.js, database inheritance is overlooked.

I’m trying to accomplish a very simple thing: extend a Users table based on a few business rules. For simplicity, I’d want to add Reader and Moderator tables and classes whose properties would differ. This is something that would be relatively easy to accomplish in .NET using NHibernate. Can I achieve the same result without using sticking everything in the same table? If not, what are the best alternatives?

Btw, I’m using Node.js with PostreSQL via Sequelize.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:05:45+00:00Added an answer on June 12, 2026 at 9:05 am

    I have not seen an ORM for SQL databases that supports inheritance yet. Even then, I believe there are other opportunities thanks to the nature of JS that you might enjoy (I sure do):

    Using jugglingdb (the one I would recommend), coupled with underscore.js (something most node.js programmers should pay attention to) you can do something like the following:

    var user_common_properties = {
        name:         String,
        bio:          Schema.Text,
        approved:     Boolean,
        joinedAt:     Date,
        age:          Number
    };
    var User = schema.define('User', user_common_properties);
    
    var Moderator = schema.define('Moderator', _.extend(user_common_properties, {
        power : String,
        level : Number
    }));
    var Reader = schema.define('Moderator', _.extend(user_common_properties, {
        lurker : Boolean
    }));
    

    While I agree it’s not the same, there are no reasons to consider this bad 🙂 I think it is very JavaScript-like.

    Also, if you want to re-use methods/validations, you can! Just assign it to them (re-use the functions) or if you want to re-use a bunch of functions, add them to an object and then extend the Reader and Moderator objects. For example…

    var repeated_methods = {
        first : function () { },
        second: function () {}
    };
    //I want to reuse this for both User and Moderator but not for Reader...
    User = _.extend(User, repeated_methods);
    Moderator = _.extend(Moderator, repeated_methods);
    

    This is very flexible and allow for has-a relationships (behaviors), which is great for horizontal reuse.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an existing SQL database, and I'm writing a node.js server that accesses
I am using: node-mysql arrtickers got around 200 values. arrtickers closure pass in values
I am using SQL Server 2008, and would like to be able to take
Using Hierarchy data type on SQL 2008. Nodes in my hierarchy go like this:
I am trying to query a NonStop SQL/MX database using JDBC. I have the
Currently, this is how I perform a query using node-mysql client.query( sql, function( error,
For example, I am using multi-table inheritance for a class Node with sub-classes ConceptNode
I am using node-mysql to update a MySQL database table from node.js. I want
I am selecting from a table that has an XML column using T-SQL. I
I'd like to perform custom HTML transformations using jQuery for Wordpress posts database (sanify

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.