我正在使用NodeJS,express,express-resource和Sequelize创建一个RESTful API,用于管理存储在MySQL数据库中的数据集.
我正在试图找出如何使用Sequelize正确更新记录.
我创建了一个模型:
module.exports = function (sequelize, DataTypes) {
return sequelize.define('Locale', {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true
},
locale: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
validate: {
len: 2
}
},
visible: {
type: DataTypes.BOOLEAN,
defaultValue: 1
}
})
}
Run Code Online (Sandbox Code Playgroud)
然后,在我的资源控制器中,我定义了一个更新操作.
在这里,我希望能够更新id与req.params变量匹配的记录.
首先,我构建一个模型,然后我使用该updateAttributes方法来更新记录.
const Sequelize = require('sequelize')
const { dbconfig } = require('../config.js')
// Initialize database connection
const sequelize = new Sequelize(dbconfig.database, dbconfig.username, dbconfig.password)
// Locale model
const Locales = sequelize.import(__dirname …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用PowerShell自动化基于种子(想想EDMX文件或DbContext)配置创建n层解决方案的过程.我希望能够打开一个框架解决方案,获取活动实例,并使用自动生成的代码填充项目文件.
我正在尝试将此处提供的示例转码为powershell,但是,我收到错误.
这是我正在测试的PowerShell代码:
首先,我执行一个小函数来引用DTE程序集.
$libs = "envdte.dll", "envdte80.dll", "envdte90.dll", "envdte100.dll"
function LoadDTELibs {
param(
$path = "\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies"
)
Process {
$libs |
ForEach {
$dll = Join-Path "$env:ProgramFiles\$path" $_
if(-not (Test-Path $dll)) {
$dll = Join-Path "${env:ProgramFiles(x86)}\$path" $_
}
Add-Type -Path $dll -PassThru | Where {$_.IsPublic -and $_.BaseType} | Sort Name
}
}
}
LoadDTELibs
Run Code Online (Sandbox Code Playgroud)
然后,我尝试创建一个对象来引用调用的结果 [System.Runtime.InteropServices.Marshal]::GetActiveObject("VisualStudio.DTE.11.0")
PS> $dte = New-Object -ComObject EnvDTE80.DTE2
New-Object : Retrieving the COM class factory for component with CLSID {00000000-0000-0000-0000-000000000000} …Run Code Online (Sandbox Code Playgroud)