```dart
import 'package:amplify_flutter/amplify_flutter.dart';

import 'models/ModelProvider.dart';

Future<void> savePostAndComment() async {
  final post = Post(
    title: 'My Post with comments',
    rating: 10,
    status: PostStatus.ACTIVE,
  );
  final comment = Comment(
    post: post, // associate the comment to the post
    content: 'Loving Amplify DataStore!',
  );

  try {
    // Make sure to safe the parent Post first
    await Amplify.DataStore.save(post);
    await Amplify.DataStore.save(comment);
  } on DataStoreException catch (e) {
    safePrint('Something went wrong querying posts: ${e.message}');
  }
}
```
