Creating New Table and Seeding data into it

Hello All,
I want to add a new table of which schema is given as follows:
new_table: {
id: {type: ‘string’, maxlength: 24, nullable: false, primary: true},
post_id: {type: ‘string’, maxlength: 24, nullable: false, references: ‘posts.id’},
description-_1: {type: ‘string’, maxlength: 2000, nullable: true},
description-_2: {type: ‘string’, maxlength: 2000, nullable: true},
created_at: {type: ‘dateTime’, nullable: false},
created_by: {type: ‘string’, maxlength: 24, nullable: false},
updated_at: {type: ‘dateTime’, nullable: true},
updated_by: {type: ‘string’, maxlength: 24, nullable: true}
},

and i want to add some seed data as well like below

{
“name”: “New_Table”,
“entries”: [
{
“post_id”: “”,
description-_1: “”,
description-_2: “”
}
]
}

and my model seems like this
var _ = require(“lodash”),
ghostBookshelf = require("./base"),
New_Table,
New_Tables;

New_Table = ghostBookshelf.Model.extend({
tableName: “translation”,

relationships: [“post”],

relationshipBelongsTo: {
post: “post”
}
});

New_Tables = ghostBookshelf.Collection.extend({
model: New_Table
});

module.exports = {
New_Table: ghostBookshelf.model(“New_Table”, New_Table),
New_Tables: ghostBookshelf.collection(“New_Tables”, New_Tables)
};

table is created but i am not able to seed data into it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.