Skip to content

List & Map Parameter in Endpoints - #194

Closed
anandsubbu007 wants to merge 9 commits into
serverpod:mainfrom
anandsubbu007:Branch-2
Closed

anandsubbu007 wants to merge 9 commits into
serverpod:mainfrom
anandsubbu007:Branch-2

Conversation

@anandsubbu007

Copy link
Copy Markdown

Added List and map parameter Support

}

/// For most cases use the corresponding method in [Database] instead.
/// If [id] in [TableRow] Already Exist then that row will be replaced by new value

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Function to batch insert or update of the list of a Table row.
but if the list of table rows with and without IDs is passed it will not work.

var serverDir = Directory(p.join(projectDir.path, name + '_server'));
if (verbose) print('Creating directory: ${serverDir.path}');
serverDir.createSync();
await serverDir.create(recursive: true);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on dev branch serverpod create mypod not working

}

Future<List<String>> testListOfString(
List<String> value,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Test case for testing purpose

var listData = (jsonDecode(input) as List?);
var dds = listData
?.map((e) => _formatArg(e, e.runtimeType, serializationManager))
.toList();

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified code to read List and map Parameter

return data;
}
} catch (error) {
// print('Error in Format Args: $error');

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to throw an error to the user about the error is creating entity Serialization

return e == null
? null
: serializationManager
.createEntityFromSerialization(e is Map ? e : jsonDecode(e));

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to find better way to avoid unnecessary jsondecode usage in this line.
because json decoder is used twice

/// This will helpful when you want to get additional info with filter like to get total items
/// available when you do pagination
extension SerializableEntityListExtension on List<SerializableEntity> {
set resStatusCode(int statusCode) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just added this to get additional details along with a list of classes.
useful is client need to know additional details with data like
in pagination total items availability, error info

@anandsubbu007

Copy link
Copy Markdown
Author

broke this pr into separate parts based on function and add in the following pr: #196

@github-actions github-actions Bot locked and limited conversation to collaborators May 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant