gpt4 book ai didi

node.js - 在哪里使用 RailwayJS 定义自定义模式

转载 作者:太空宇宙 更新时间:2023-11-03 23:46:38 29 4
gpt4 key购买 nike

文档只是说“或定义自定义架构(非杂耍),例如 mongoose。请注意,如果是自定义架构,所有 jugglingdb 功能当然都将被禁用。”

但是..

这个模式到底应该在哪里创建?

最佳答案

我相信您仍然可以在 db/schema.js 中创建它。例如:

customSchema(function () {

var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');

var Schema = mongoose.Schema, ObjectId = Schema.ObjectId;

var BlogPost = new Schema({
author : ObjectId
, title : String
, body : String
, date : Date
});

var Post = mongoose.model('BlogPost', BlogPost);
Post.modelName = 'BlogPost'; // this is for some features inside railway (helpers, etc)

module.exports['BlogPost'] = Post;

});

关于node.js - 在哪里使用 RailwayJS 定义自定义模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10032524/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com