Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何自定义数据库的 schema? #5125

Closed
hooozen opened this issue Dec 5, 2022 Discussed in #5124 · 4 comments
Closed

如何自定义数据库的 schema? #5125

hooozen opened this issue Dec 5, 2022 Discussed in #5124 · 4 comments

Comments

@hooozen
Copy link

hooozen commented Dec 5, 2022

Discussed in https://github.com/orgs/hexojs/discussions/5124

Originally posted by hooozen December 5, 2022
Hexo(或 warehouse) 是否提供了合适的方法或钩子,来修改 Schema,或者自定义 Schema。能够使我能在所有的文件资源被 Process 完毕后,利用 Post 和 Categories 等 model 来自定义我自己的 Model 呢?并且能够在 Generator 被执行前完成。

我现在找不到一个合适的时机:若在 ProcessAfter 后执行,由于数据库的插入等操作是异步执行的,那么 Generator 就读取不到正确的数据了。如果在 ProcessBefor 前执行,那么我就得自己处理资源文件,而无法利用 Hexo 已经为我们构建好的 Post 和 Categories 数据。

在现的 Hexo 有没有很好的解决方法呢?

@heyanyidui
Copy link

应该目前 hexo 不支持这个操作吧。(非官答复)

@hooozen
Copy link
Author

hooozen commented Dec 30, 2022

谢谢,是不是可以增加这样的钩子呢?感觉也不会对原有功能产生副作用,但却可以极大丰富自定义的程度。

@byteluo
Copy link

byteluo commented Feb 27, 2023

我之前也遇到过类似的需求,好像也做不了。把它源码改了,判断一下 Promise 😁

@hooozen
Copy link
Author

hooozen commented Feb 27, 2023

😬我在 generator 里处理后直接存内存里了

@hooozen hooozen closed this as completed Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants