Skip to content

Commit 01e4bfd

Browse files
author
pedro
committed
update:更新帮助脚本
1 parent 9d48673 commit 01e4bfd

2 files changed

Lines changed: 37 additions & 44 deletions

File tree

tests/helper/fake.js

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,24 @@ require("./initial");
22
const { db } = require("lin-mizar/lin/db");
33
// eslint-disable-next-line no-unused-vars
44
const { User, Group, Auth } = require("lin-mizar/lin");
5-
// eslint-disable-next-line no-unused-vars
6-
const { Book } = require("../../app/models/book");
75

86
const run = async () => {
9-
// await Book.bulkCreate([
10-
// {
11-
// title: "深入理解计算机系统",
12-
// author: "Randal E.Bryant",
13-
// summary:
14-
// "从程序员的视角,看计算机系统!\n本书适用于那些想要写出更快、更可靠程序的程序员。通过掌握程序是如何映射到系统上,以及程序是如何执行的,读者能够更好的理解程序的行为为什么是这样的,以及效率低下是如何造成的。",
15-
// image: "https://img3.doubanio.com/lpic/s1470003.jpg"
16-
// },
17-
// {
18-
// title: "C程序设计语言",
19-
// author: "(美)Brian W. Kernighan",
20-
// summary:
21-
// "在计算机发展的历史上,没有哪一种程序设计语言像C语言这样应用广泛。本书原著即为C语言的设计者之一Dennis M.Ritchie和著名计算机科学家Brian W.Kernighan合著的一本介绍C语言的权威经典著作。",
22-
// image: "https://img3.doubanio.com/lpic/s1106934.jpg"
23-
// }
24-
// ]);
25-
// const group = new Group();
26-
27-
// group.name = "普通分组";
28-
// group.info = "就是一个分组而已";
29-
// await group.save();
30-
31-
// const user = new User();
32-
// user.nickname = "pedro";
33-
// user.password = "123456";
34-
// await user.save();
7+
const group = new Group();
358

36-
// await Auth.create({
37-
// auth: "删除图书",
38-
// module: "图书",
39-
// group_id: group.id
40-
// });
9+
group.name = "普通分组";
10+
group.info = "就是一个分组而已";
11+
await group.save();
4112

42-
const group = await Group.findOne({
43-
where: {
44-
name: "普通分组"
45-
}
46-
});
47-
const user = await User.findOne({
48-
where: {
49-
nickname: "pedro"
50-
}
51-
});
52-
user.group_id = group.id;
13+
const user = new User();
14+
user.nickname = "pedro";
15+
user.password = "123456";
5316
await user.save();
5417

18+
await Auth.create({
19+
auth: "删除图书",
20+
module: "图书",
21+
group_id: group.id
22+
});
5523
db.close();
5624
};
5725

tests/helper/fake_book.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require("./initial");
2+
const { db } = require("lin-mizar/lin/db");
3+
const { Book } = require("../../app/models/book");
4+
5+
const run = async () => {
6+
await Book.bulkCreate([
7+
{
8+
title: "深入理解计算机系统",
9+
author: "Randal E.Bryant",
10+
summary:
11+
"从程序员的视角,看计算机系统!\n本书适用于那些想要写出更快、更可靠程序的程序员。通过掌握程序是如何映射到系统上,以及程序是如何执行的,读者能够更好的理解程序的行为为什么是这样的,以及效率低下是如何造成的。",
12+
image: "https://img3.doubanio.com/lpic/s1470003.jpg"
13+
},
14+
{
15+
title: "C程序设计语言",
16+
author: "(美)Brian W. Kernighan",
17+
summary:
18+
"在计算机发展的历史上,没有哪一种程序设计语言像C语言这样应用广泛。本书原著即为C语言的设计者之一Dennis M.Ritchie和著名计算机科学家Brian W.Kernighan合著的一本介绍C语言的权威经典著作。",
19+
image: "https://img3.doubanio.com/lpic/s1106934.jpg"
20+
}
21+
]);
22+
db.close();
23+
};
24+
25+
run();

0 commit comments

Comments
 (0)