Skip to content

oldshen/aqueduct_mysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

配置

首先确保已配置好aqueduct相关环境

~/.pub_cache/bin下新建 aqueduct_mysql文件

cd  ~/.pub_cache/bin
touch aquduct_mysql

aqueduct_mysql中写入:

# set aqueduct_mysql package's path
dart "xxxx/aqueduct_mysql/bin/aqueduct_mysql.dart" "$@"

# The VM exits with code 253 if the snapshot version is out-of-date.
# If it is, we need to delete it and run "pub global" manually.
exit_code=$?
if [ $exit_code != 253 ]; then
  exit $exit_code
fi

给予aqueduct_mysql执行权限:

chmod +x aqueduct_mysql

使用

在项目中添加依赖:

dependencies:
  aqueduct: ^3.3.0
  aqueduct_mysql: ^0.0.1

使用aqueduct_mysql命令

  1. 生成migration文件:
aqueduct_mysql db generate
  1. 生成数据库
aqueduct_mysql db upgrade --connect mysql://username:password@host:port/databasename
  1. 添加认证client
aqueuct_mysql auth add-client --id newclient --connect mysql://username:password@host:port/databasename
  1. 使用MySqlPersistentStore
  final MySqlPersistentStore persistentStore = MySqlPersistentStore(
        _config.database.username,
        _config.database.password,
        _config.database.host,
        _config.database.port,
        _config.database.databaseName);

    context = ManagedContext(dataModel, persistentStore);
    /// ......
   final result= await Query(context, values: user).insert();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages