https://github.com/marvelbark2/postgrest-java
https://github.com/marvelbark2/postgrest-java
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/marvelbark2/postgrest-java
- Owner: marvelbark2
- Created: 2022-08-18T13:02:16.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-08-18T13:15:19.000Z (over 3 years ago)
- Last Synced: 2025-01-19T06:18:38.788Z (12 months ago)
- Language: Java
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# postgrest-java
Current version: Memo
example:
```java
//rest URL
String url = "";
// public key
String pubKey = "";
//Example map to preload request header with payload like apikey
Map headers = new HashMap<>(Map.of("apikey", pubKey ));
String schema = "api";
PostgrestClient client = new PostgrestClient(
url, headers, schema
);
PostgrestQueryBuilder contactQB = client.from("contacts");
// SELECT id, name FROM contacts;
PostgrestFilterBuilder contactsFilter = contactQB.select("id, name");
// Contact is just a POJO class
Contact[] contactsName = contactsFilter.get(Contact[].class);
System.out.println(Arrays.toString(contactsName));
// SELECT * FROM contacts;
PostgrestFilterBuilder allContactsFilter = contactQB.select();
Contact[] allContacts = allContactsFilter.get(Contact[].class);
System.out.println(Arrays.toString(allContacts));
contactQB.insert(new ArrayList(new HashMap<>(
Map.of("col", "val", "col2", "val2", ...)
))).get(...)
//Always call get method to fetch the api
```