• التصفية المعقدة

التصفية المعقدة

تتمتع الكائنات (أي كيان يمكنك إنشاء خاصية مخصصة له) بميزة التصفية المعقدة، التي تتيح لك التصفية حسب الخاصية.

يكون بنية التصفية المعقدة كالتالي:

complex_filters<OrGroup<AndGroup<AndObject>[]>[]>

أو، في نصوص الإستعلام:

complex_filters[OrGroupIndex][AndGroupIndex][AndObjectKey]

وفي JS يكون كالتالي:

{
    complex_filters: [
        // this is OrGroup
        [
            // this is AndGroup
            [
                // this is AndObject
                {
                    field: string,
                    operation: string,
                    value: string|number|undefined,
                },
                // another AndObject
                {
                    field: string,
                    operation: string,
                    value: string|number|undefined,
                },
            ]
        ]
    ]
}

حيث:

  1. field: هو الاسم الداخلي للخاصية.
  2. operation: exists | doesntExist | equal | notEqual | in | notIn | greater | greaterOrEqual | less | lessOrEqual.
  3. value: القيمة المُقارنة بها، وهي مطلوبة مع جميع العمليات عدا exists وdoesntExist، ويجب عدم إرسالها مع هاتين العمليتين.

مثال

يُرجع هذا الاستعلام كل جهة اتصال اسمها الأول محمد وعمرها أقل من 30، إضافة إلى كل جهة اتصال حالتها الاجتماعية معبّأة.

https://app.alaaqat.com/api/contacts?page=1&complex_filters[0][0][field]=firstname&complex_filters[0][0][operation]=equal&complex_filters[0][0][value]=Mohammad&complex_filters[0][1][field]=age&complex_filters[0][1][operation]=less&complex_filters[0][1][value]=30&complex_filters[1][0][field]=marital_status&complex_filters[1][0][operation]=exists