上一页 1 ··· 87 88 89 90 91 92 93 94 95 ··· 469 下一页
摘要: In JavaScript, the factory pattern isn't much more than a function that returns an object without using the new keyword. ES6 arrow functions allow us 阅读全文
posted @ 2022-08-26 17:44 Zhentiw 阅读(19) 评论(0) 推荐(0) 编辑
摘要: Source: https://javascriptpatterns.vercel.app/patterns/design-patterns/singleton-pattern With the Singleton Pattern, we restrict the instantiation of 阅读全文
posted @ 2022-08-26 15:44 Zhentiw 阅读(17) 评论(0) 推荐(0) 编辑
摘要: Module pattern provide a way to have both public and private pieces with the export keyword. This protects values from leaking into the global scope o 阅读全文
posted @ 2022-08-26 15:18 Zhentiw 阅读(32) 评论(0) 推荐(0) 编辑
摘要: import type only imports declarations to be used for type annotations and declarations. It always gets fully erased, so there’s no remnant of it at ru 阅读全文
posted @ 2022-08-24 14:44 Zhentiw 阅读(73) 评论(0) 推荐(0) 编辑
摘要: function isError(err: any): err is Error { return err instanceof Error; } try { somethingRisky() } catch(err: unknown) { if (isError(err)) { console.l 阅读全文
posted @ 2022-08-24 14:23 Zhentiw 阅读(17) 评论(0) 推荐(0) 编辑
摘要: In some ways // @ts-expect-error can act as a suppression comment, similar to // @ts-ignore. The difference is that // @ts-ignore will do nothing if t 阅读全文
posted @ 2022-08-24 01:46 Zhentiw 阅读(515) 评论(0) 推荐(0) 编辑
摘要: CrudController: 查看代码 export const getOne = model => async (req, res) => { try { const doc = model .findOne({ createdBy: req.user._id, _id: req.params. 阅读全文
posted @ 2022-08-23 19:25 Zhentiw 阅读(21) 评论(0) 推荐(0) 编辑
摘要: Each model controller: import { crudControllers } from '../../utils/crud' import { Item } from './item.model' export default crudControllers(Item) You 阅读全文
posted @ 2022-08-23 19:23 Zhentiw 阅读(11) 评论(0) 推荐(0) 编辑
摘要: Model: import mongoose from 'mongoose' const itemSchema = new mongoose.Schema( { name: { type: String, required: true, trim: true, maxlength: 50 }, st 阅读全文
posted @ 2022-08-23 19:20 Zhentiw 阅读(13) 评论(0) 推荐(0) 编辑
摘要: Model: import mongoose from 'mongoose' const itemSchema = new mongoose.Schema( { name: { type: String, required: true, trim: true, maxlength: 50 }, st 阅读全文
posted @ 2022-08-22 21:00 Zhentiw 阅读(14) 评论(0) 推荐(0) 编辑
上一页 1 ··· 87 88 89 90 91 92 93 94 95 ··· 469 下一页