I need to create a simple database for use in an Angular/Node demo. What is the path of least resistance to adding such a database to my demo?
我需要创建一个简单的数据库,用于Angular / Node演示。将这样的数据库添加到我的演示中的阻力最小的路径是什么?
Incidentally, I cannot use the MEAN stack.
顺便说一句,我不能使用MEAN堆栈。
Edit: I failed to mention that I'm running the demo from my local environment--from my laptop.
编辑:我没有提到我从我的本地环境运行演示 - 从我的笔记本电脑。
1 个解决方案
#1
3
The path of least resistance would be to use Sequelize
and sqlite3
in your application.
阻力最小的路径是在您的应用程序中使用Sequelize和sqlite3。
Start off by running npm install sequelize sqlite3
.
首先运行npm install sequelize sqlite3。
Then in your code
然后在你的代码中
var Sequelize = require( 'sequelize' )
var connection = Sequelize.connect( undefined, {
dialect: 'sqlite',
storage: __dirname + '/db.sqlite'
})
Tada, you have a database connection syncing to a local sqlite DB.
Tada,你有一个与本地sqlite DB同步的数据库连接。
You'll likely need to consult the Sequelize documentation to use this connection.
您可能需要查阅Sequelize文档才能使用此连接。
If, however, you wanted an API for your angular demo, json-server is what you're looking for.
但是,如果您想要一个用于角度演示的API,那么json-server就是您正在寻找的。
#1
3
The path of least resistance would be to use Sequelize
and sqlite3
in your application.
阻力最小的路径是在您的应用程序中使用Sequelize和sqlite3。
Start off by running npm install sequelize sqlite3
.
首先运行npm install sequelize sqlite3。
Then in your code
然后在你的代码中
var Sequelize = require( 'sequelize' )
var connection = Sequelize.connect( undefined, {
dialect: 'sqlite',
storage: __dirname + '/db.sqlite'
})
Tada, you have a database connection syncing to a local sqlite DB.
Tada,你有一个与本地sqlite DB同步的数据库连接。
You'll likely need to consult the Sequelize documentation to use this connection.
您可能需要查阅Sequelize文档才能使用此连接。
If, however, you wanted an API for your angular demo, json-server is what you're looking for.
但是,如果您想要一个用于角度演示的API,那么json-server就是您正在寻找的。