43
loading...
This website collects cookies to deliver better user experience
// IMAGINARY DOCUMENT DATABASE
// COLLECTION
const usersCollection =[
// documents are object like
{
name: 'John Doe',
email: '[email protected]',
phone: '234703635235'
},
//...other documents
]
// IMAGINARY DOCUMENT DATABASE
// COLLECTION
const usersCollection =[
{
name: 'John Doe',
email: '[email protected]',
address: {
city: 'port harcourt',
zip: 500102,
state: 'rivers',
country: 'nigeria'
}
},
//...other documents
]
// IMAGINARY DOCUMENT DATABASE
// COLLECTION
const usersCollection =[
{
name: 'John Doe',
address: {
city: 'port harcourt'
zip: 500102,
state: 'rivers',
country: 'nigeria'
},
hobbies: ['swiming', 'reading', 'singing'],
contact: {
socialMedia: {
facebook: "link-to-facebook",
linkedIn: 'link-to-linkedin'
},
normal: {
email: '[email protected]',
phone: '234703635235'
}
}
},
//...other documents
]
// IMAGINARY DOCUMENT DATABASE
// COLLECTION
const usersCollection =[
{
id: 12AM8H12HYTRS6F24WBVT,
name: 'John Doe',
address: {
city: 'port harcourt'
zip: 500102,
state: 'rivers',
country: 'nigeria'
},
hobbies: ['swiming', 'reading', 'singing'],
contact: {
socialMedia: {
facebook: "link-to-facebook",
linkedIn: 'link-to-linkedin'
},
normal: {
email: '[email protected]',
phone: '234703635235'
}
},
friends: ['LK0G678YUOPQZXOTVU', 'WE19BC67UIL0QA17LJH', ...otherFriends],
following: ['LK0G678YUOPQZXOTVU', 'WE19BC67UIL0QA17LJH', ...otherPeopleUserFollows],
followers: ['LK0G678YUOPQZXOTVU', 'WE19BC67UIL0QA17LJH', ...otherFollowers],
posts: ['LK0G678YUOPQZXOTVU', 'WE19BC67UIL0QA17LJH', ...otherPosts]
},
//...other documents
]
// IMAGINARY FORNTEND
// get the user somehow
const friends = user.friends.map(id => getEachDocumentSomehow(id))
const posts = user.posts.map(id => getEachPostSomehow(id))
graphQL
, graphQL can handle situations like this effortlessly and in a scalable manner, you can scan through this article to get a basic intro to graphQL.faunadb
as your database solution for your next project. I hope you found this useful