hunghvu / hungvu.tech

The official repository for hungvu.tech
https://hungvu.tech
3 stars 0 forks source link

Implement a mechanism so multiselect option can have all available choices #126

Closed hunghvu closed 7 months ago

hunghvu commented 7 months ago

Related to #112.

hunghvu commented 7 months ago

Sample of idea.


const payload = require('payload');

payload.collections['collection_name'].Model.distinct('field_name', {status: {$eq: '*condition*'}}, async (err, data) => {
  if (err) {
    // handle error
  } else {
    // work with unique data values
    const uniqueValues = [...new Set(data)];
    console.log(uniqueValues);
  }
});
hunghvu commented 7 months ago

Commit 6a1992e reduces payload from the CMS from 80kb to 20kb, and cuts a huge amount of DB operations too.

hunghvu commented 7 months ago

Consider as done.