Skip to content

Commit

Permalink
Can Select From an object
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarParra committed May 15, 2024
1 parent 97bf9f2 commit 059a45d
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .idea/datum.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/illuminatedCloud.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions PROJECT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Project DATUM

1. Write a QueryBuilder
2. Write a In Memory DB
3. Write a System (Salesforce) DB
4. They should all work with the same interface
24 changes: 24 additions & 0 deletions force-app/spec/QueryBuilderTest.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@IsTest
private class QueryBuilderTest {
// RED, GREEN, REFACTOR

@IsTest
static void canSelectFromAnObject_systemDb() {
// Given an account in the DB
Account account = new Account(Name = 'Test Account');
QDB.doInsert(account);

// By default when you don't specify any fields, it is going to select the Id
QueryBuilder builder = QueryBuilder.of('Account');

// When I run the query
List<Account> accounts = builder.query(builder);

Assert.areEqual(1, accounts.size());
Assert.areEqual(account.Id, accounts[0].Id);
}

// TODO: Can query an object
// TODO: Can query specific fields out of an object
// TODO: Support bulk insert
}
5 changes: 5 additions & 0 deletions force-app/spec/QueryBuilderTest.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
5 changes: 5 additions & 0 deletions force-app/src/QDB.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public with sharing class QDB {
public static void doInsert(Account account) {
insert account;
}
}
5 changes: 5 additions & 0 deletions force-app/src/QDB.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>
9 changes: 9 additions & 0 deletions force-app/src/QueryBuilder.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
public with sharing class QueryBuilder {
public static QueryBuilder of(String objectType) {
return new QueryBuilder();
}

public List<Account> query(QueryBuilder queryBuilder) {
return [SELECT Id FROM Account];
}
}
5 changes: 5 additions & 0 deletions force-app/src/QueryBuilder.cls-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>60.0</apiVersion>
<status>Active</status>
</ApexClass>

0 comments on commit 059a45d

Please sign in to comment.