-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDAO.cls
66 lines (56 loc) · 1.37 KB
/
DAO.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
public inherited sharing class DAO {
private static DAO daoIns;
public static DAO getInstance() {
if (daoIns == null) {
daoIns = new DAO();
}
return daoIns;
}
@TestVisible
private static void mockInstance(DAO mockObj) {
daoIns = mockObj;
}
public Database.SaveResult doInsert(
SObject record,
Schema.SObjectType sObjectType
) {
return Database.insert(record);
}
public Database.SaveResult[] doInsert(
List<SObject> records,
Schema.SObjectType sObjectType
) {
return Database.insert(records);
}
public Database.SaveResult doUpdate(
SObject record,
Schema.SObjectType sObjectType
) {
return Database.update(record);
}
public Database.SaveResult[] doUpdate(
List<SObject> records,
Schema.SObjectType sObjectType
) {
return Database.update(records);
}
public List<Database.UpsertResult> doUpsert(
SObject[] records,
SObjectField sObjField
) {
return Database.upsert(records, sObjField);
}
public Database.DeleteResult doDelete(Id recordId) {
return Database.delete(recordId);
}
public Database.DeleteResult[] doDelete(List<Id> recordIds) {
return Database.delete(recordIds);
}
public List<SObject> doQuery(
String query,
Map<String, Object> binds,
AccessLevel accessLevel
) {
return Database.queryWithBinds(query, binds, accessLevel);
}
}