igara/syonet_seven

View on GitHub
nodejs/api/src/models/elasticsearch/sound.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { client } from "@api/models/elasticsearch/client";
const index = "sounds";
const type = "sound";

export const create = async (name: string, artist: string, peaks: string) => {
  await client.index({
    index,
    body: {
      name,
      artist,
      peaks,
    },
    type,
  });
};

export const search = async (peaks: string) => {
  return await client.search({
    index,
    body: {
      query: {
        match: { peaks },
      },
    },
    type,
  });
};