Skip to content

findOne

AGenson edited this page Mar 4, 2018 · 7 revisions

findOne

Find only one entity by query, and filter the fields of the result


Parameters

Property Type Default Description
ctx Object required Will serve to call a service action: ctx.call
search Object -

search field details:

Sub-Property Type Default Description
query Object - Clause WHERE --> ex: { username: "username", age: { $lt: 5 } }
filter Array.<String> - ex: ["id", "username"]

Return

Type: Promise

If an entity was found :

// res = entity found
Promise.resolve({
	name: "Operation Successful",
	message: `Search Complete: element found`,
	data: res
});

Else (nothing found / an error occured) :

Promise.reject({ ... });

cf - details about errors

Clone this wiki locally