Skip to content

Commit

Permalink
Merge pull request #6 from dinukaamarasinghe817/redis-client
Browse files Browse the repository at this point in the history
Fix formatting issues in Redis examples and tests
  • Loading branch information
dinukaamarasinghe817 authored Mar 15, 2024
2 parents c54e923 + 32874f0 commit 70852cf
Show file tree
Hide file tree
Showing 26 changed files with 19 additions and 43 deletions.
13 changes: 7 additions & 6 deletions examples/social_media/main.bal
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import social_media.entities;

import ballerina/http;
import ballerina/persist;

Expand All @@ -24,7 +24,7 @@ public type User record {|
string email;
|};

public type Post record{|
public type Post record {|
readonly int id;
string title;
string content;
Expand Down Expand Up @@ -91,10 +91,11 @@ service /social_media on new http:Listener(9090) {
// Define the resource to handle GET requests for users
resource function get users() returns User[]|error {
stream<User, persist:Error?> users = self.dbClient->/users;
return from User user in users select user;
return from User user in users
select user;
}

resource function delete users/[string firstName]/[string lastName]() returns http:NoContent | http:InternalServerError {
resource function delete users/[string firstName]/[string lastName]() returns http:NoContent|http:InternalServerError {
entities:User|persist:Error result = self.dbClient->/users/[firstName]/[lastName].delete();
if result is persist:Error {
return http:INTERNAL_SERVER_ERROR;
Expand Down Expand Up @@ -137,7 +138,7 @@ service /social_media on new http:Listener(9090) {
}

// Define the resource to handle DELETE request for post by id
resource function delete posts/[int id]() returns http:NoContent | http:InternalServerError {
resource function delete posts/[int id]() returns http:NoContent|http:InternalServerError {
entities:Post|persist:Error result = self.dbClient->/posts/[id].delete();
if result is persist:Error {
return http:INTERNAL_SERVER_ERROR;
Expand Down Expand Up @@ -166,7 +167,7 @@ service /social_media on new http:Listener(9090) {
}

// Define the resource to handle DELETE request for comment by id
resource function delete comments/[int id]() returns http:NoContent | http:InternalServerError {
resource function delete comments/[int id]() returns http:NoContent|http:InternalServerError {
entities:Comment|persist:Error result = self.dbClient->/comments/[id].delete();
if result is persist:Error {
return http:INTERNAL_SERVER_ERROR;
Expand Down
9 changes: 4 additions & 5 deletions examples/social_media/persist/model.bal
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/persist as _;
import ballerina/time;

Expand All @@ -22,7 +21,7 @@ public enum Gender {
FEMALE
}

public type User record{|
public type User record {|
readonly string firstName;
readonly string lastName;
string email;
Expand All @@ -31,15 +30,15 @@ public type User record{|
Gender gender;
boolean isMarried;
string spouseName?;
Post[] post;
Post[] post;
|};

public type Post record{|
public type Post record {|
readonly int id;
string title;
string content;
User user;
Comment[] comment;
Comment[] comment;
|};

public type Comment record {|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/io;

public function main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/persist as _;
import ballerina/time;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/io;

public function main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/persist as _;
import ballerina/time;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/io;

public function main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ballerina/persist as _;
// Copyright (c) 2024 WSO2 LLC. (http://www.wso2.org).
//
// WSO2 LLC. licenses this file to you under the Apache License,
Expand All @@ -13,9 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/time;
import ballerina/persist as _;

type Workspace record {|
readonly string workspaceId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/io;

public function main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ballerina/persist as _;
// Copyright (c) 2024 WSO2 LLC. (http://www.wso2.org).
//
// WSO2 LLC. licenses this file to you under the Apache License,
Expand All @@ -13,9 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/time;
import ballerina/persist as _;

type Workspace record {|
readonly string workspaceId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/io;

public function main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/persist as _;
import ballerina/time;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/io;

public function main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/persist as _;
import ballerina/time;

Expand All @@ -23,8 +22,8 @@ type User record {|
time:Date birthDate;
string mobileNumber;
Post[] posts;
Follow? leader;
Follow? follower;
Follow? leader;
Follow? follower;
|};

type Post record {|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/io;

public function main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/persist as _;
import ballerina/time;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/io;

public function main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/persist as _;
import ballerina/time;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/io;

public function main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ballerina/persist as _;
// Copyright (c) 2024 WSO2 LLC. (http://www.wso2.org).
//
// WSO2 LLC. licenses this file to you under the Apache License,
Expand All @@ -13,9 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/time;
import ballerina/persist as _;

type Workspace record {|
readonly string workspaceId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/io;

public function main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ballerina/persist as _;
// Copyright (c) 2024 WSO2 LLC. (http://www.wso2.org).
//
// WSO2 LLC. licenses this file to you under the Apache License,
Expand All @@ -13,9 +14,7 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/time;
import ballerina/persist as _;

type Workspace record {|
readonly string workspaceId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/io;

public function main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/persist as _;
import ballerina/time;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/io;

public function main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/persist as _;
import ballerina/time;

Expand All @@ -23,8 +22,8 @@ type User record {|
time:Date birthDate;
string mobileNumber;
Post[] posts;
Follow? leader;
Follow? follower;
Follow? leader;
Follow? follower;
|};

type Post record {|
Expand Down

0 comments on commit 70852cf

Please sign in to comment.