GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — changes :elephant: · bitgord/fullstack-javascript@84768fa

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • 9-db-connect
    • Procfile
    • db.js
    • package.json
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎9-db-connect/Procfile‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: node app.js
Collapse file

‎9-db-connect/db.js‎

Copy file name to clipboard
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var util = require('util')
2+
var mongodb = require ('mongodb')
3+
var Db = mongodb.Db
4+
var Connection = mongodb.Connection
5+
var Server = mongodb.Server
6+
var host = '127.0.0.1'
7+
var port = 27017
8+
9+
// Script that will work on Heroku with MongoHQ/Compose
10+
11+
/*
12+
var dbConnUrl = process.env.MONGOHQ_URL ||
13+
'mongodb://127.0.0.1:27017'
14+
var host = url.parse(dbConnUrl).hostname
15+
var port = new Number(url.parse(dbConnUrl).port)
16+
*/
17+
18+
var db=new Db ('test', new Server(host, port, {}))
19+
db.open(function(error, connection){
20+
console.log('error: ', error)
21+
var adminDb = db.admin()
22+
adminDb.listDatabases(function(err, dbs) {
23+
console.log('error: ', error)
24+
console.log('databases: ', dbs.databases)
25+
db.close()
26+
})
27+
})
Collapse file

‎9-db-connect/package.json‎

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "node-example",
3+
"version": "0.0.1",
4+
"dependencies": {
5+
"mongodb": "2.0.49",
6+
"url": "0.11.0"
7+
},
8+
"engines": {
9+
"node": ">=0.6.x"
10+
}
11+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.