Skip to content

Instantly share code, notes, and snippets.

@jamesperi
Last active April 3, 2019 16:04
Show Gist options
  • Save jamesperi/d4f0d769deb1e12e8b67838c0bd2be67 to your computer and use it in GitHub Desktop.
Save jamesperi/d4f0d769deb1e12e8b67838c0bd2be67 to your computer and use it in GitHub Desktop.
Create Book Query
const books = [
{
id: 1,
name: "Name Of The Wind",
author: {
id: 100,
name: "Jim",
},
readers: [
{
id: 101,
name: "Dave",
},{
id: 102,
name: "Mike",
},{
id: 103,
name: "Steve",
},
]
},
{
id: 1,
name: "Gone With The Wind",
author: {
id: 100,
name: "Jim"
},
readers: [
{
id: 102,
name: "Mike"
},{
id: 103,
name: "Steve"
},
]
},
{
id: 1,
name: "Wind In My Hair",
author: {
id: 102,
name: "Mike",
},
readers: [
{
id: 101,
name: "Dave",
},{
id: 103,
name: "Steve",
},
]
},
{
id: 1,
name: "Who Broke Wind",
author: {
id: 101,
name: "Dave",
},
readers: [
{
id: 100,
name: 'Jim',
}, {
id: 103,
name: "Steve",
}, {
id: 104,
name: "Mary"
}
]
}
]
const bookNamesByUserId = id => {
/* returns array of book names where id matches a user id of the author or a reader */
}
const result = bookNamesByUserId(103)
console.log(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment