应该是我忘了npm install…
By providing [userId] as a second argument, we are just telling “useEffect()” to run only if the certain value (userId) has changed between the component re-renders.
useEffect => (() => {
fetchUser();
}, [userId]);
The LIMIT clause is not part of standard SQL. It’s supported as a vendor extension to SQL by MySQL, PostgreSQL, and SQLite.
由于我用的aqua studio自带一个输入limit的inputbox,所以我就没纠结。当然也可以尝试用mongo JS。
redux action post, 把requestbody的json放在body里
用:onSelectionChanged={onSelectionChanged}
const onSelectionChanged = () => {
const selectedRows = gridApi.getSelectedRows();
}
messagebodyreader not found for media type=text/plain, type=class java.lang.Exception, genericType=class java.lang.Exception
…
cannot construct instance of … no creators, like default construct, exist: cannot deserialize from Object value(no delegate-or property-based creator)
I got here searching for this error:
No Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator
Nothing to do with Retrofit but if you are using Jackson this error got solved by adding a default constructor to the class throwing the error. More here: https://www.baeldung.com/jackson-exception
果然加了@AllArgsConstructor and @NoArgsConstructor然后就可以了…
select lambda, click alt+enter, then click extract to method reference
-> this::someFunction …
find max date in Object:
https://stackoverflow.com/questions/20995664/how-to-find-max-date-in-listobject
sum of values for each key:
https://stackoverflow.com/questions/51428490/java-8-stream-mapstring-liststring-sum-of-values-for-each-key
我的实现:
java stream filter example:
public String getDate(Document document) {
// document.getFields() is List
return document.getFields().stream()
.filter(field -> field.getName().equals("doc_date"))
.map(field -> field.getValue().get(0))
.collect(Collectors.toList())
.get(0).toString();
}
java stream groupBy and pick Object with max value example:
// documents is List
// custom key for stream groupBy
Funcion<Document, List<String>> createCustomKey =
document -> Arrays.<String>asList(document.getId(), document.getName());
// groupBy by custom key
Map<List<String>, List<Document>> documentsGroupByCustomKey = documents.stream().collect(Collectors.groupingBy(createCustomKey, Collectors.toList()));
List<Document> latestDocuments = new ArrayList<>();
for (Map.Entry<List<String>, List<Document>> entry : documentsGroupByCustomKey.entrySet()) {
// get Object with max date
latestDocuments.add(Collections.max(entry.getValue(), Comparator.comparing(this::getDate)));
}