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 8563695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:01:11+00:00 2026-06-11T17:01:11+00:00

Is it possible to have one abstraction class to be used my mongoDB class

  • 0

Is it possible to have one abstraction class to be used my mongoDB class and mysql class. Since, in mysql we can perform the insert, update and delete statements in one function but mongodb we cannot.

Or they should have separate database abstraction layer

 // I can pass INSERT,UPDATE and DELETE query to this function but for monbodb I cannot 
mysql 
public function doNonQuery($sql){
        mysql_query($sql);
}

mongoDB
public function insert($tableName,$query){
    $collection = new MongoCollection($db,$tableName);
    $a  = $query
    $collection->insert($a);
}

public function update($tableName,$query){
    $collection = new MongoCollection($db,$tableName);
    $a  = $query
    $collection->update($a);
}
  • 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-11T17:01:12+00:00Added an answer on June 11, 2026 at 5:01 pm

    You are not thinking at the right level of abstraction. Rather than trying to abstract the Insert, Update, and Delete operations (which is what your code sample is doing), you should be thinking about abstracting your domain. This will let you come up with an interface where you can insert, update, and delete objects.. for example:

    interface IDatabaseCollection<T> where T : IDatabaseEntity
    {
        void Insert(T item);
        void Update(T item);
        void Delete(T item);
    }
    

    Now you could implement a SQLDatabaseCollection and a MongoDatabaseCollection that both implement IDatabaseCollection.

    The above is a basic example, and there are of course many other ways to do it. But it’s the direction you need to start thinking in when dealing with abstractions.

    In short, your abstraction is too low-level and you need to elevate it to make it a higher level abstraction.

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

Sidebar

Related Questions

it's possible to have one entity object (class, e.g. User) for more entity models
Possible stupid question: let's say I have two apps contained within one project. Can
Is it possible to have one CSS class reference another? Instead of rewriting all
Is it possible: to have one field in class, but different names for it
Is it possible to have one jQuery ready block executed after all others have
Is it possible to have more than one application running on the iphone accessing
first time use JTree. Just wondering is it possible to have more than one
Is it possible to have git pull and git push in one git command?
Is it possible to have two app.config files where one app.config serves as a
Possible Duplicate: I have an array of integers, how do I use each one

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.