我正在学习node.js和sequelizer,我遇到了一个问题,即我使用Sequelizer创建了一个User模型,不幸的是当我想在index.js中运行sequelizer.sync(); 它在控制台中向我显示结果,但它不会创建表格。
我的型号:
const Sequelize = require('sequelize');
const sequelize = require('../util/database');
const User = sequelize.define('user', {
id: {
type: Sequelize.INTEGER,
autoIncrement: true,
allowNull: false,
primaryKey: true
},
name: {
type: Sequelize.TEXT,
allowNull: false
},
surname: {
type: Sequelize.TEXT,
allowNull: false
}
});
module.exports = User;
Run Code Online (Sandbox Code Playgroud)
我的数据库配置
const Sequelize = require('sequelize');
const sequelize = new Sequelize('node-nauka', 'root', '', {
dialect: 'mysql',
host: 'localhost'
});
module.exports = sequelize;
Run Code Online (Sandbox Code Playgroud)
索引.js
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const …
Run Code Online (Sandbox Code Playgroud) 我有以下问题,我正在使用 ng-zorro-antd 做应用程序,现在我想做 2 个组件,一个负责登录,另一个负责注册。不幸的是,问题是创建这些组件后,如何在路由/登录或/注册之后进行,然后这两个组件使用主模板,例如我有一个侧边栏。我怎样才能让他们不使用任何模板?我希望登录和注册仅显示登录和注册表单。
\n\n我在许多模板中看到,作为 BlankComponent 的一部分编写并且它可以工作,不幸的是它对我不起作用。
\n\n我的路线:
\n\nconst routes: Routes = [\n {\n path: \'\',\n component: DashboardComponent\n },\n {\n path: \'login\',\n component: LoginComponent\n }\n];\n
Run Code Online (Sandbox Code Playgroud)\n\n现在,当我编写 BlankComponent 时,出于明显的原因,它表明不存在这样的组件,如果我输入路径本身,它也将不起作用,因为它不会给出应该加载什么组件。如果我输入LoginComponent,它会加载LoginComponent给我,但是这样我会加载共享的侧边栏,我想得到这样的效果:进入路由寄存器后我会看到相同的内容RegisterComponent,没有侧边栏等. 与共享。
\n\n我的应用程序组件:
\n\n<nz-layout>\n <nz-sider [nzBreakpoint]="\'lg\'" [nzZeroTrigger]="zeroTrigger" nzCollapsible [(nzCollapsed)]="isCollapsed" [nzTrigger]="triggerTemplate"\n [nzWidth]="250" style="background-color: #000;">\n <div class="logo">\n <img src="../assets/logo.png" class="logo-img" />\n </div>\n <ul nz-menu [nzTheme]="\'dark\'" [nzMode]="\'inline\'" [nzInlineCollapsed]="isCollapsed">\n <li nz-submenu>\n <span title><i nz-icon type="money-collect" theme="outline"></i><span class="nav-text">Ksi\xc4\x99gowo\xc5\x9b\xc4\x87</span></span>\n <ul>\n <li nz-menu-item><i nz-icon type="right-circle" theme="outline"></i> Lista u\xc5\xbcytkownik\xc3\xb3w</li>\n <li nz-menu-item><i nz-icon type="right-circle" theme="outline"></i> …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 docker + bitbucket 管道进行自动发布;不幸的是,我有一个问题。我阅读了 Docker Hub 上的管道部署说明,并创建了以下模板:
# This is a sample build configuration for Docker.
# Check our guides at https://confluence.atlassian.com/x/O1toN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: atlassian/default-image:2
pipelines:
default:
- step:
services:
- docker
script: # Modify the commands below to build your repository.
# Set $DOCKER_HUB_USERNAME and $DOCKER_HUB_PASSWORD as environment variables in …
Run Code Online (Sandbox Code Playgroud) 当我使用实体框架时,我有简单的 WPF Net Core 应用程序,我有 DbContext,但是当我添加迁移时,我收到错误:
PM> add-migration init
Build started...
Build succeeded.
Unable to create an object of type 'AppDbContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
Run Code Online (Sandbox Code Playgroud)
我的应用程序设置.json
{
"ConnectionStrings": {
"SqlConnection": "Server=DESKTOP-K6R1EB3\\tester;Database=test;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序数据库上下文
using Microsoft.EntityFrameworkCore;
namespace WpfApp1
{
public class AppDbContext : DbContext
{
public DbSet<Person> Person { get; set; }
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{
}
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序.xaml.cs
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.IO;
using System.Windows; …
Run Code Online (Sandbox Code Playgroud) 我的 NgRx 效果有问题。
应用程序正确添加到商店,不幸的是我的请求效果没有执行,即在启动添加新车时,将其添加到商店,就是这样。问题是我的效果没有控制台日志,没有由于错误的 url 导致的 http 错误,什么都没有。
我的应用程序代码:
减速器
import { Action } from '@ngrx/store';
import * as CarActions from './car.actions';
import { Car } from 'src/models/car.model';
const initialState: Car = {
brand: '',
model: ''
};
export function carReducer(state: Car[] = [initialState], action: CarActions.Actions) {
switch (action.type) {
case CarActions.ADD_CAR:
return [...state, action.payload];
case CarActions.ADD_CAR_FAIL:
return {
...state,
carError: action.payload,
};
default:
return state;
}
}
Run Code Online (Sandbox Code Playgroud)
状态
import { Car } from './../../models/car.model';
export interface AppState {
readonly …
Run Code Online (Sandbox Code Playgroud) 我在自定义模块中覆盖前端控制器时遇到问题。我有模块:
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
class cartlimit extends Module
{
public function __construct()
{
$this->name = 'cartlimit';
$this->tab = 'front_office_features';
$this->author = 'somedata';
$this->version = '1.0.0';
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('cart limit');
$this->description = $this->l('module for cart limit');
}
public function install()
{
return parent::install();
}
public function uninstall()
{
return parent::uninstall();
}
}
Run Code Online (Sandbox Code Playgroud)
在我的模块中,我有控制器 override/controllers/CartController.php ,代码如下:
<?php
use PrestaShop\PrestaShop\Adapter\Presenter\Cart\CartPresenter;
class CartControllerCore extends FrontController
{ …
Run Code Online (Sandbox Code Playgroud) 我遇到以下问题,我创建了一个应用程序,将游戏类别和游戏本身添加到数据库中。我创建了一个关系,但是不幸的是,当我添加到数据库中时,出现错误。
模型绑定的复杂类型不能为抽象或值类型,并且必须具有无参数构造函数。
游戏类别模型
using System.Collections.Generic;
namespace relationship.Models
{
public class GameCategory
{
public int Id { get; set; }
public string Name { get; set; }
public ICollection<Game> Game { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
游戏模型
namespace relationship.Models
{
public class Game
{
public int GameId { get; set; }
public string Name { get; set; }
public GameCategory Category { get; set; }
public int CategoryId { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
视图模型
using relationship.Models;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic; …
Run Code Online (Sandbox Code Playgroud) 我有以下问题,使用 symfony 上传文件,它以原始分辨率和扩展名移动。现在我想创建第二个文件,它是第一个文件的副本,但分辨率为 320px x 60px 并且它应该在名称中,即原始文件的名称如何:my_images.png 我会像要命名为 my_images_320x60.png 的副本
正确上传后,我的图片在 http://localhost/uploads/i/my_images.png 可用
我的上传看起来像这样:
$logoFile = $this->getValidatorParameter('logo_file');
$storage = $this->get('file.event.storage');
$file = $storage->upload($logoFile->getValue());
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何做到这一点?图像已复制,我有它的路径,但我无法更改其分辨率和名称:(
我的 Node.js API 有问题。我的 API 在端口 3000 上运行,角度前端在端口 4200 上运行。
当我从 Angular 向 API 发送请求时,出现 CORS 错误。我尝试了三种不同的解决方案,但仍然不起作用。
应用程序.use(cors());
Run Code Online (Sandbox Code Playgroud)app.use((req, res, next) => { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); res.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); next(); })
Run Code Online (Sandbox Code Playgroud)app.use(cors({ origin: 'http://frontend.com:4200' }));
上述方法均无效,即我仍然始终收到 CORS 错误。当我从邮递员发送请求时,一切正常。
我的实际代码:
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const carRoutes = require('./routes/car');
const sequelize = require('./util/db');
const cors = require('cors');
sequelize.sync().catch(error => {
console.log(error); …
Run Code Online (Sandbox Code Playgroud)