我想从关注模型中获取限制为 2 的用户图像。
楷模
const Follow = connector.define('Follow', {
no: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
follower_id: {
type: Sequelize.INTEGER,
allowNull: true
},
target_id: {
type: Sequelize.INTEGER,
allowNull: true
},
isDelete: {
type: Sequelize.BOOLEAN,
allowNull: false
},
create_dt,
delete_dt
}
const User = connector.define('User', {
no: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
username: {
type: Sequelize.STRING,
allowNull: false
},
email: {
type: Sequelize.STRING,
allowNull: false
},
password: {
type: Sequelize.STRING,
allowNull: false
},
profile_img: {
type: …Run Code Online (Sandbox Code Playgroud)经过 Jest 和 Enzyme 测试的组件具有一定的功能。然后这个函数使用一个导入的库。
它会犯一些错误。
it('Emoji should be rendered without error', () => {
const messageItem = shallow(
<MessageItem {...props}/>
)
...
})
Run Code Online (Sandbox Code Playgroud)
import * as getUrls from 'get-urls';
export class MessageItem extends Component <Props> {
state = {
isOpenThread: false,
isAddEmoji: false,
containedUrl: ''
}
getContainUrl = () => {
//getUrls makes an error!
const urls = getUrls(this.props.content).values();
const firstUrl: string = urls.next().value;
return firstUrl
}
...
render(){
return (... <UrlInfoArea {...props} url={this.getContainUrl()} />))
}
} …Run Code Online (Sandbox Code Playgroud) enzyme ×1
include ×1
jestjs ×1
join ×1
node.js ×1
orm ×1
reactjs ×1
sequelize.js ×1
typescript ×1