PPA — Phalcon Rest Api (JPA in Java) Examples

Примеры использования PPA

Подробнее тут https://github.com/sergeytkachenko/phalcon-rest-jpa

Выборка всех записей

ppa/s/cars
[
  {
    "id": "1",
    "title": "Ceed",
    "brand_id": "1",
    "date_create": "2016-03-05 14:45:31"
  },
  {
    "id": "2",
    "title": "A8",
    "brand_id": "3",
    "date_create": "2016-03-05 14:45:31"
  },
  {
    "id": "3",
    "title": "A-class",
    "brand_id": "4",
    "date_create": "2016-03-05 14:47:36"
  },
  {
    "id": "4",
    "title": "X1",
    "brand_id": "3",
    "date_create": "2016-03-05 14:48:08"
  }
]

Выборка по id

"ppa/s/cars/findByTitleContainingOrId?title=a&id=1"
[
  {
    "id": "3",
    "title": "A-class",
    "brand_id": "4",
    "date_create": "2016-03-05 14:47:36"
  }
]

Поиск по всем колонкам сущности

ppa/s/cars/search?search=a
[
  {
    "id": "2",
    "title": "A8",
    "brand_id": "3",
    "date_create": "2016-03-05 14:45:31"
  },
  {
    "id": "3",
    "title": "A-class",
    "brand_id": "4",
    "date_create": "2016-03-05 14:47:36"
  }
]

Поиск по определенным колонкам сущности

ppa/s/cars/search?search=45&columns[]=dateCreate
[
  {
    "id": "1",
    "title": "Ceed",
    "brand_id": "1",
    "date_create": "2016-03-05 14:45:31"
  },
  {
    "id": "2",
    "title": "A8",
    "brand_id": "3",
    "date_create": "2016-03-05 14:45:31"
  }
]

Поиск по колонке, которая начинается на *

ppa/s/cars/findByTitleStartingWith?title=ce
[
  {
    "id": "1",
    "title": "Ceed",
    "brand_id": "1",
    "date_create": "2016-03-05 14:45:31"
  }
]

Поиск по колонке, которая содержит вхождение *

ppa/s/cars/findByTitleContaining?title=a
[
  {
    "id": "2",
    "title": "A8",
    "brand_id": "3",
    "date_create": "2016-03-05 14:45:31"
  },
  {
    "id": "3",
    "title": "A-class",
    "brand_id": "4",
    "date_create": "2016-03-05 14:47:36"
  }
]

Комбинация правил

"ppa/s/cars/findByTitleContainingOrId?title=a&id=1"
[
  {
    "id": "1",
    "title": "Ceed",
    "brand_id": "1",
    "date_create": "2016-03-05 14:45:31"
  },
  {
    "id": "2",
    "title": "A8",
    "brand_id": "3",
    "date_create": "2016-03-05 14:45:31"
  },
  {
    "id": "3",
    "title": "A-class",
    "brand_id": "4",
    "date_create": "2016-03-05 14:47:36"
  }
]
PPA — Phalcon Rest Api (JPA in Java) Examples
1 vote, 5.00 avg. rating (94% score)