How to get randomly sorted recordsets in Strapi

This page summarizes the projects mentioned and recommended in the original post on dev.to

Nutrient - The #1 PDF SDK Library
Bad PDFs = bad UX. Slow load times, broken annotations, clunky UX frustrates users. Nutrient’s PDF SDKs gives seamless document experiences, fast rendering, annotations, real-time collaboration, 100+ features. Used by 10K+ devs, serving ~half a billion users worldwide. Explore the SDK for free.
nutrient.io
featured
CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
  1. Strapi

    🚀 Strapi is the leading open-source headless CMS. It’s 100% JavaScript/TypeScript, fully customizable, and developer-first.

    This project stack is Next.js for the frontend and Strapi for the backend. In this post, we will focus on the backend side and see how we can return random recordsets of a Strapi collection type.

  2. Nutrient

    Nutrient - The #1 PDF SDK Library. Bad PDFs = bad UX. Slow load times, broken annotations, clunky UX frustrates users. Nutrient’s PDF SDKs gives seamless document experiences, fast rendering, annotations, real-time collaboration, 100+ features. Used by 10K+ devs, serving ~half a billion users worldwide. Explore the SDK for free.

    Nutrient logo
  3. Next.js

    The React Framework

    This project stack is Next.js for the frontend and Strapi for the backend. In this post, we will focus on the backend side and see how we can return random recordsets of a Strapi collection type.

  4. Knex

    A query builder for PostgreSQL, MySQL, CockroachDB, SQL Server, SQLite3 and Oracle, designed to be flexible, portable, and fun to use.

    First, we need to get all recordsets randomly sorted. To achieve this, we will need to build a query. Strapi is using Bookshelf as an ORM. So we can start by getting our Partnership model, so we can run a query on it. Inside the query, we get a knex (this is the query builder that Bookshelf uses under the hood) query builder instance. On this query builder instance, we can there ask to order recordsets randomly. Let's try this:

  5. Bookshelf

    A simple Node.js ORM for PostgreSQL, MySQL and SQLite3 built on top of Knex.js

    First, we need to get all recordsets randomly sorted. To achieve this, we will need to build a query. Strapi is using Bookshelf as an ORM. So we can start by getting our Partnership model, so we can run a query on it. Inside the query, we get a knex (this is the query builder that Bookshelf uses under the hood) query builder instance. On this query builder instance, we can there ask to order recordsets randomly. Let's try this:

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Why Beginners CRUSH IT with TypeScript

    5 projects | dev.to | 19 Nov 2024
  • NodeJS Security Best Practices

    11 projects | dev.to | 19 Feb 2024
  • I Hate NestJS

    4 projects | news.ycombinator.com | 24 Oct 2023
  • What's wrong with Node.js ORMs? Thousands of issues? Why?

    3 projects | /r/webdev | 16 Oct 2023
  • Contributing to Tech Communities: How Open-Source can land you a job and get you out of the Skill Paradox 💼

    4 projects | dev.to | 26 Sep 2023

Did you know that JavaScript is
the 3rd most popular programming language
based on number of references?