我正在尝试从我的webpack项目中的pug模板输出单个html文件.我遇到的问题是pug-loader将html渲染到文件中.
我的webpack.config:
const path = require('path');
const glob = require('glob');
const webpack = require('webpack');
const src = path.resolve(__dirname, 'src');
const dist = path.resolve(__dirname, 'dist');
module.exports = {
context: src,
entry: {
pug: glob.sync('./**/*.pug', {
cwd: src
}),
index: path.resolve(src, 'index.js')
},
output: {
path: dist,
filename: '[name].js'
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['es2015'].map(dep =>
require.resolve(`babel-preset-${dep}`)
) // Fix for lerna symlinked deps
}
}
},
{
test: /\.pug$/, …Run Code Online (Sandbox Code Playgroud) 如何运行排名函数以在给定的续集模型上生成属性?
例如,给定模型:
Players.init(
{
id: {
type: DataTypes.INTEGER,
primaryKey: true,
allowNull: false
},
rating: type: DataTypes.FLOAT
},
{ sequelize }
)
Run Code Online (Sandbox Code Playgroud)
我想rank在运行时获得一个属性Players.getAll({ rank: rating })。这将生成类似于以下内容的 SQL:
SELECT id, rating, RANK() OVER (ORDER BY rating DESC) as rank FROM players
Run Code Online (Sandbox Code Playgroud)
我将如何使用sequelize来做到这一点?