// 不使用 lowdb ,可以使用内存作为数据存储。不会持久化。 const Mock = require('mockjs') function mock() { return Mock.mock({ // 'id|1': ['@integer(1, 3)', '@id', '@increment'], 'id': '@guid', 'idCard': Mock.mock('@id'), 'token|1': [/[A-z0-9]{32}/, '@guid'], 'eFullName|1': ['@name', '@first @last'], // 英文姓名 'cFullName|1': ['@cname', '@cfirst@clast'], // 中文姓名 email: '@email', ip: '@ip', region: '@region', // Random.region() province: '@province', // Random.province() city: ['@city', '@city(true)'], // Random.city( prefix? ) county: ['@county', '@county(true)'], // Random.county( prefix? ) zip: '@zip', // Random.zip() // Random.datetime( format? ) Random.date( format? ) Random.time( format? ) datetime: '@datetime(yyyy yy y MM M dd d HH H hh h mm m ss s SS S A a T)', timestamp: +Mock.Random.date('T'), 'color|1': ['@color', '@hex', '@rgb', '@rgba', '@hsl'], cparagraph: '@cparagraph(1, 3)', // Random.cparagraph( min?, max? ) csentence: '@csentence(1, 3)', // Random.csentence( min?, max? ) ctitle: '@ctitle(8, 13)', // Random.ctitle( min?, max? ), account: '@cname', password: '@string("lower", 6)', title: '@title(5, 10)', forecast: '@float(0, 100, 2, 2)', importance: '@integer(1, 3)', 'status|1': ['published', 'draft'], comment_disabled: true, pageviews: '@integer(300, 5000)', absolutePath: '@/username @/token' }) } module.exports = Array.from(new Array(2), () => mock())