Skip to content

ABKey/project-local-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

This project is a library application that allows users to view, search, and interact with a database of books.


Account functions

findAccountById()

The findAccountById() function in public/src/accounts.js has two parameters, in the following order:

  • An array of account objects.
  • A string ID of a single account object.

It returns the account object that has the matching ID.

Example:

findAccountById(accounts, "5f446f2ecfaf0310387c9603");
/*
  {
    "id": "5f446f2ecfaf0310387c9603",
    "name": {
      "first": "Esther",
      "last": "Tucker"
    },
    ...
  }
*/

sortAccountsByLastName()

The sortAccountsByLastName() function in public/src/accounts.js has a single parameter:

  • An array of account objects.

It returns a sorted array of the provided account objects. The objects are sorted alphabetically by last name.

Example:

sortAccountsByLastName(accounts);
/*
  [
    {
      "name": {
        "first": "Kirby",
        "last": "Alston"
      },
      ...
    },
    {
      "name": {
        "first": "Toni",
        "last": "Ball"
      },
      ...
    },
  ]  
*/

getTotalNumberOfBorrows()

The getTotalNumberOfBorrows() function in public/src/accounts.js has two parameters, in the following order:

  • An account object.
  • An array of all book objects.

It returns a number that represents the number of times the account's ID appears in any book's borrows array.

Example:

getTotalNumberOfBorrows(account, books); // 22

getBooksPossessedByAccount()

The getBooksPossessedByAccount function in public/src/accounts.js has three parameters, in the following order:

  • An account object.
  • An array of all book objects.
  • An array of all author objects.

It returns an array of book objects, including author information, that represents all books currently checked out by the given account. Look carefully at the object below, as it's not just the book object; the author object is nested inside of it.

Example:

getBooksPossessedByAccount(account, books, authors);
/*
  [
    {
      id: "5f447132320b4bc16f950076",
      title: "est voluptate nisi",
      genre: "Classics",
      authorId: 12,
      author: {
        id: 12,
        name: {
          first: "Chrystal",
          last: "Lester",
        },
      },
      borrows: [
        {
          id: "5f446f2e6059326d9feb9a68",
          returned: false,
        },
        ...
      ],
    },
  ]
*/

Book functions

findAuthorById()

The findAuthorById() function in public/src/books.js has two parameters, in the following order:

  • An array of author objects.
  • An integer ID of a single author object.

It returns the author object that has the matching ID.

Example:

findAuthorById(authors, 11);
/*
  {
    id: 11,
    name: {
      first: "Luz",
      last: "Beach",
    },
  }
*/

findBookById()

The findBookById() function in public/src/books.js has two parameters, in the following order:

  • An array of book objects.
  • A string ID of a single book object.

It returns the book object that has the matching ID.

Example:

findBookById(books, "5f447132320b4bc16f950076");
/*
  {
    id: "5f447132320b4bc16f950076",
    title: "est voluptate nisi",
    ...
  }
*/

partitionBooksByBorrowedStatus()

The partitionBooksByBorrowedStatus() function in public/src/books.js has a single parameter:

  • An array of book objects.

It returns an array with two arrays inside of it. All of the inputted books are present in either the first or second array.

The first array contains book objects that represent the books that are currently checked out, while the second array contains book objects that represent the books that have been returned. You can check for the return status by looking at the first transaction object in the borrows array.

Example:

partitionBooksByBorrowedStatus(books);
/*
  [
    [
      {
        id: "5f447132d487bd81da01e25e",
        title: "sit eiusmod occaecat eu magna",
        genre: "Science",
        authorId: 8,
        borrows: [
          {
            id: "5f446f2e2cfa3e1d234679b9",
            returned: false,
          },
          ...
        ]
      },
      ...
    ],
    [
      {
        id: "5f44713265e5d8d17789beb0",
        title: "tempor occaecat fugiat",
        genre: "Travel",
        authorId: 16,
        borrows: [
          {
            id: "5f446f2e4eff1030e7316861",
            returned: true,
          },
          ...
        ]
      },
      ...
    ]
  ]
*/

getBorrowersForBook()

The getBorrowersForBook() function in public/src/books.js has two parameters, in the following order:

  • A book object.
  • An array of all account objects.

It should return an array of ten or fewer account objects that represents the accounts given by the IDs in the provided book's borrows array. However, each account object should include the returned entry from the corresponding transaction object in the borrows array.

Example:

getBorrowersForBook(book, accounts);
/*
  [
    {
      id: "5f446f2e4eff1030e7316861",
      returned: true,
      picture: "https://api.adorable.io/avatars/75/[email protected]",
      age: 37,
      name: {
        first: "Barber",
        last: "Waters",
      },
      company: "KEGULAR",
      email: "[email protected]",
      registered: "Tuesday, April 14, 2020 9:15 PM",
    },
    {
      id: "5f446f2ecc5c4787c403f844",
      returned: true,
      picture: "https://api.adorable.io/avatars/75/[email protected]",
      age: 34,
      name: {
        first: "Dyer",
        last: "Trevino",
      },
      company: "SLAX",
      email: "[email protected]",
      registered: "Saturday, August 1, 2015 8:13 PM",
    },
  ]
*/

Home functions

getTotalBooksCount()

The getTotalBooksCount() function in public/src/home.js has a single parameter:

  • An array of book objects.

It returns a number that represents the number of book objects inside of the array.

Example:

getTotalBooksCount(books); // 100

getTotalAccountsCount()

The getTotalAccountsCount() function in public/src/home.js has a single parameter:

  • An array of accounts.

It returns a number that represents the number of account objects inside of the array.

Example:

getTotalAccountsCount(accounts); // 75

getBooksBorrowedCount()

The getBooksBorrowedCount() function in public/src/home.js has a single parameter:

  • An array of books.

It returns a number that represents the number of books that are currently checked out of the library. This number can be found by looking at the first transaction object in the borrows array of each book. If the transaction says the book has not been returned (i.e. returned: false), the book is currently being borrowed.

Example:

getBooksBorrowedCount(accounts); // 65

getMostCommonGenres()

The getMostCommonGenres() function in public/src/home.js has a single parameter:

  • An array of book objects.

It returns an array containing five objects or fewer that represents the most common occurring genres, ordered from most common to least.

Each object in the returned array has two keys:

  • The name key which represents the name of the genre.
  • The count key which represents the number of times the genre occurs.

Even if there is a tie, the array should only contain no more than five objects.

Example:

getMostCommonGenres(books);
/*
  [
    { name: "Nonfiction", count: 9 },
    { name: "Historical Fiction", count: 7 },
    { name: "Thriller", count: 7 },
    ...
  ]
*/

getMostPopularBooks()

The getMostPopularBooks() function in public/src/home.js has a single parameter:

  • An array of book objects.

It returns an array containing five objects or fewer that represents the most popular books in the library. Popularity is represented by the number of times a book has been borrowed.

Each object in the returned array has two keys:

  • The name key which represents the title of the book.
  • The count key which represents the number of times the book has been borrowed.

Even if there is a tie, the array should only contain no more than five objects.

Example:

getMostPopularBooks(books);
/*
  [
    { name: "incididunt nostrud minim", count: 30 },
    { name: "culpa do sint", count: 30 },
    { name: "ullamco est minim", count: 29 },
    ...
  ]
*/

getMostPopularAuthors()

The getMostPopularAuthors() function in public/src/home.js has two parameters, in the following order:

  • An array of book objects.
  • An array of author objects.

It returns an array containing five objects or fewer that represents the most popular authors whose books have been checked out the most. Popularity is represented by finding all of the books written by the author and then adding up the number of times those books have been borrowed.

Each object in the returned array has two keys:

  • The name key which represents the first and last name of the author.
  • The count key which represents the number of times the author's books have been borrowed.

Array does not contain more than five objects.

Example:

getMostPopularAuthors(books, authors);
/*
  [
    { name: "Cristina Buchanan", count: 112 },
    { name: "Tami Hurst", count: 83 },
    { name: "Chrystal Lester", count: 80 },
    ...
  ]
*/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published