Я пытаюсь создать таблицу с использованием PostgreSQL.Код выше корректно аутентифицируется.Проблема, с которой я сейчас сталкиваюсь, заключается в том, как правильно создать таблицу «устройства» и записать в нее данные.
const Sequelize = require('sequelize');
const env = require('./config');
sequelize = new Sequelize({
database: '******',
dialect: 'postgres',
username: '********',
password: '******',
host: '********',
port: 3211
});
sequelize.authenticate().then(() => {
console.log("Connected to DB");
})
.catch((err) => {
console.log(err);
})
function insertIntoPostgres(filename, data) {
var fileToCreate =
`/${env.azurePG.data_store_pg.folder}/${filename}.json`;
var options = {
streamContents: new Buffer(JSON.stringify(data))
}
filesystemClient.fileSystem.create(env.azurePG.data_store_pg.account_name_pg, fileToCreate, options)
.then(res => {})
.catch(err => {
console.log("error inserting into postgres: ", err);
});
};
// Export the above methods
module.exports = {
insertIntoPostgres
}
Вот часть моего кода, которая, на мой взгляд, неверна из приведенного выше кода:
filesystemClient.fileSystem.create(env.azurePG.data_store_pg.account_name_pg, fileToCreate, options)
.then(res => {})
.catch(err => {
console.log("error inserting into postgres: ", err);
});
};
my config.js
module.exports = {
PGDATABASE : "******",
PGPORT : 3211,
azurePG : {
PGUSER : "*******",
PGHOST : "********",
PGPASSWORD : "*******",
data_store_pg : {
account_name_pg : "********",
folder : "devices"
}
}
};
Есть идеи, где проблема?