Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.3 kB
7
Indexable
Never
// import 'dart:io';
import 'package:dart_appwrite/dart_appwrite.dart';
import 'dart:math';

void main() {
  try {
    // final Map<String, dynamic> env = Platform.environment;
    // final Client client = Client(endPoint: env['APPWRITE_ENDPOINT']);
    // client.setProject(env['APPWRITE_PROJECT']);
    // client.setKey(env['API_KEY']);
    final Client client = Client(endPoint: 'http://localhost/v1');
    client.setProject('6139cb70bdcd9');
    client.setKey(
        'cc69472603a4c39d050af4e5f6cc6db3f58c8e4f893f45cdbcb2b191a155fb462f18c4c323e5a62b3bd6efbe22d40f22600b1a06fb8b7bf16def0152be4beab7c25b6ded9a5d8a2114e3e807dd5175e8aa5416e6e9bd526140974aa0174e142d1358cfb5ce1c87eb59cb44e696cb0fb0480ff60abe38d86d635012918ce5b359s');
    // final Account account = Account(client);
    final Database database = Database(client);
    final Random random = Random();
    final int randInt = random.nextInt(1000);
    database.createDocument(
      collectionId: '6139cb91b2d89',
      write: ['*'],
      read: ['*'],
      data: {
        'title': 'Google Pixel 6 $randInt',
        'description': 'Latest phone by Google',
        'price': 500,
        'images': ['http://localhost/v1/storage/files/613bf62094c82/view?project=6139cb70bdcd9&mode=admin']
      },
    );
  } catch (e) {
    print(e);
  }
}