Skip to content

Commit

Permalink
add required schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
jainpranayr committed Dec 27, 2021
1 parent 8dcd92f commit f6ca471
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 6 deletions.
17 changes: 17 additions & 0 deletions backend/schemas/comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
name: "comment",
title: "Comment",
type: "document",
fields: [
{
name: "postedBy",
title: "PostedBy",
type: "postedBy",
},
{
name: "comment",
title: "Comment",
type: "string",
},
],
}
57 changes: 57 additions & 0 deletions backend/schemas/pin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
export default {
name: "pin",
title: "Pin",
type: "document",
fields: [
{
name: "title",
title: "Title",
type: "string",
},
{
name: "about",
title: "About",
type: "string",
},
{
name: "destination",
title: "Destination",
type: "url",
},
{
name: "category",
title: "Category",
type: "string",
},
{
name: "image",
title: "Image",
type: "image",
options: {
hotspot: true,
},
},
{
name: "userId",
title: "UserID",
type: "string",
},
{
name: "postedBy",
title: "PostedBy",
type: "postedBy",
},
{
name: "save",
title: "Save",
type: "array",
of: [{ type: "save" }],
},
{
name: "comments",
title: "Comments",
type: "array",
of: [{ type: "comment" }],
},
],
}
6 changes: 6 additions & 0 deletions backend/schemas/postedBy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
name: "postedBy",
title: "PostedBy",
type: "reference",
to: [{ type: "user" }],
}
17 changes: 17 additions & 0 deletions backend/schemas/save.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
name: "save",
title: "Save",
type: "document",
fields: [
{
name: "postedBy",
title: "PostedBy",
type: "postedBy",
},
{
name: "userId",
title: "UserId",
type: "string",
},
],
}
15 changes: 9 additions & 6 deletions backend/schemas/schema.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
// First, we must import the schema creator
import createSchema from 'part:@sanity/base/schema-creator'
import createSchema from "part:@sanity/base/schema-creator"

// Then import schema types from any plugins that might expose them
import schemaTypes from 'all:part:@sanity/base/schema-type'
import schemaTypes from "all:part:@sanity/base/schema-type"
import user from "./user"
import pin from "./pin"
import comment from "./comment"
import postedBy from "./postedBy"
import save from "./save"

// Then we give our schema to the builder and provide the result to Sanity
export default createSchema({
// We name our schema
name: 'default',
name: "default",
// Then proceed to concatenate our document type
// to the ones provided by any plugins that are installed
types: schemaTypes.concat([
/* Your types here! */
]),
types: schemaTypes.concat([user, pin, comment, postedBy, save]),
})
17 changes: 17 additions & 0 deletions backend/schemas/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
name: "user",
title: "User",
type: "document",
fields: [
{
name: "username",
title: "Username",
type: "string",
},
{
name: "image",
title: "Image",
type: "string",
},
],
}

0 comments on commit f6ca471

Please sign in to comment.