简体   繁体   中英

massive.connectSync not a function

Why do I get this error, massive.connectSync is not a function when I run server.js. It works on my mac, but not my windows. Please help solve this enter code here error

var express = require("express");
var app = express();
var http = require('http');
var massive = require("massive");
var connectionString = "postgres://massive:@localhost/MarketSpace";

// connect to Massive and get the db instance. You can safely use the
// convenience sync method here because its on app load
// you can also use loadSync - it's an alias
var massiveInstance = massive.connectSync({connectionString : connectionString})

// Set a reference to the massive instance on Express' app:
app.set('db', massiveInstance);
http.createServer(app).listen(8080);

Synchronous functions are no longer supported, and the connect function itself no longer exists, it's all promises all the way:

var express = require("express");
var app = express();
var http = require('http');
var massive = require("massive");
var connectionString = "postgres://massive:@localhost/MarketSpace";

massive(connectionString).then(massiveInstance => {
    app.set('db', massiveInstance);
    http.createServer(app).listen(8080);
});

Note that massive requires node > 6. If you are using and older version you'll need to update node in order to use massive.

Docs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM