我正在阅读createAsyncThunk文档,并对流程感到有点困惑。这是来自文档:
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit'
import { userAPI } from './userAPI'
// First, create the thunk
const fetchUserById = createAsyncThunk(
'users/fetchByIdStatus',
async (userId, thunkAPI) => {
const response = await userAPI.fetchById(userId)
return response.data
}
)
// Then, handle actions in your reducers:
const usersSlice = createSlice({
name: 'users',
initialState: { entities: [], loading: 'idle' },
reducers: {
// standard reducer logic, with auto-generated action types per reducer
},
extraReducers: {
// Add reducers for additional …Run Code Online (Sandbox Code Playgroud) 所以,我有一个从主分支检出的分支。
掌握
我在模型上有一些变化。现在,我完成了必须在模型分支中完成的工作。
同样,我将创建下一个分支并在那里做一些工作并推送到该分支本身。
那么,接下来我该怎么做呢?
git pull origin models
git checkout master
git merge models
Run Code Online (Sandbox Code Playgroud)
git pull origin nextBranch
git checkout master
git merge nextBranch
Run Code Online (Sandbox Code Playgroud)
现在,有人说,“始终与主人保持同步”。我不明白这是什么意思。我们不会强迫任何东西去掌握,对吧?我们正在推动当地分支机构。另外,我看到人们总是这样做git pull origin master。有人可以向我解释正确的工作流程吗?.
我不知道,我只是糊涂了。
因此,我有这篇文章架构,我想在其中创建一个独特的 slug。
const mongoose = require("mongoose")
const Schema = mongoose.Schema
var URLSlug = require('mongoose-slug-generator')
const articleSchema = new Schema({
title: { type: String, required: true },
description: { type: String, required: true },
userId: { type: Schema.Types.ObjectId, ref: "User" },
slug: { type: "String", slug: "title", unique: true }
}, { timestamps: true })
articleSchema.pre("save", function(next) {
this.slug = this.title.split(" ").join("-")
next()
})
articleSchema.plugin(URLSlug("title", {field: "Slug"}))
const Article = mongoose.model("Article", articleSchema)
module.exports = Article
Run Code Online (Sandbox Code Playgroud)
这是文章控制器
newArticle: (req, …Run Code Online (Sandbox Code Playgroud)