express absolutely can be used along with other packages.
I have a project that uses mongoose, an ODM for Mongo. Interestingly I started the project initially with mysql as the DB, using Sequelize, an ORM for MySQL, PostGres, et al.. Changing from one to the other was very basic.
Here's what one of my mongoose models looks like:
module.exports = function(mongoose) {
var Schema = mongoose.Schema
, findOrCreate = require('mongoose-findorcreate');
var ResourceCostSchema = new Schema({
name: String,
cost: Number
});
ResourceCostSchema.plugin(findOrCreate);
console.log('Resource Costs');
mongoose.model('ResourceCost', ResourceCostSchema);
};
I have an autoloader of sorts so that to load all of my models I simply have to require the directory.. the index.js in that dir takes care of the rest...
The most relevant portion:
var fs = require('fs');
module.exports = function (app) {
var mongoose = require('mongoose')
, config = app.get('config');
// Prepare mongodb connect string
var connectString = 'mongodb://';
if ((typeof config.db.user !== 'undefined' && config.db.user != null) && (typeof config.db.pass !== 'undefined' && config.db.pass != null)) {
connectString += config.db.user + ':' + config.db.pass + '@';
}
connectString += config.db.host;
if (typeof config.db.port !== 'undefined') {
connectString += ':' + config.db.port;
}
connectString += '/' + config.db.name;
// Support defining mongodb connection string via MONGOLAB_URI environment variable (e.h. on Heroku)
if (typeof process.env.MONGOLAB_URI !== 'undefined') {
connectString = process.env.MONGOLAB_URI;
}
// Set up DB connection
var db = mongoose.connection;
// -- SNIP --
// Add Email and Url field types:
var mongooseTypes = require('mongoose-types');
mongooseTypes.loadTypes(mongoose);
console.log('Preparing database...');
// Process all .js files in the directory except the index.js file
fs.readdirSync(__dirname).forEach(function(file) {
if (file === 'index.js' || file.substr(file.lastIndexOf('.') + 1) !== 'js') {
return;
}
var name = file.substr(0, file.indexOf('.'));
require('./' + name)(mongoose);
});
app.set('db', mongoose);
};
I have a similar "autoloader" for my routes, which are broken into a few different files, etc.
Express definitely is a framework. However, it's a much less robust framework, and a rather different paradigm than laravel. The asynchronous nature of JS can be considerably more challenging to work with, and since more often than not you're actually building the entire server, not just the app that runs atop apache or something, there is more effort involved. Thinking about it that way you should realize that you're actually not doing much work to build a completely custom web/chat/etc server with node.