Skip to content

Instantly share code, notes, and snippets.

@SylvainEstevez
Last active July 26, 2016 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SylvainEstevez/4d9dd78286da0c6e1b2934d244a7b305 to your computer and use it in GitHub Desktop.
Save SylvainEstevez/4d9dd78286da0c6e1b2934d244a7b305 to your computer and use it in GitHub Desktop.
weights
const tokenFieldsWeights = {
id: 100,
dependency_id: 80,
task_id: 80,
actor_id: 60,
actor_owner_id: 40,
actor_owner_type: 30
actor_type: 20
};
const operatorWeights = {
eq: 100,
in: 80,
nin: 70,
ne: 60,
gt: 50,
gte: 50,
lt: 50,
lte: 50
};
/**
* id__eq = 1 => 10000
* id__in = 1,2,3 => 8000
* actor_id__gte = 155 => 3000
* actor_id__eq = 2 => 6000
* actor_owner_type__eq = 2 => 3000
* actor_owner_type__in = customer,organisation => 2100
*/
@nicolasgramlich
Copy link

What determines the tokenFieldsWeights ? I assume PK > FKs > Uniques > Ints > Strings or sth?

@nicolasgramlich
Copy link

Btw, is there "like" filter?

@SylvainEstevez
Copy link
Author

tokenFieldsWeights defaults to [primaryKey, ...allOtherFields] and is to be defined/fine-grained manually for each resource.

like operator, there was one in noot but I did not report it to restypie. Doable if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment