是否可以让ES6类getter从ES2017 await/async函数返回一个值.
class Foo {
async get bar() {
var result = await someAsyncOperation();
return result;
}
}
function someAsyncOperation() {
return new Promise(function(resolve) {
setTimeout(function() {
resolve('baz');
}, 1000);
});
}
var foo = new Foo();
foo.bar.should.equal('baz');
Run Code Online (Sandbox Code Playgroud) 在我之前的问题中搜索范围纬度/经度坐标 我的解决方案是创建下表.
mysql> select * from spatial_table where MBRContains(GeomFromText('LINESTRING(9 9, 11 11)'), my_spots);
+------+---------------------------------+
| id | my_spots | my_polygons |
+------+-------------+-------------------+
| 1 | $@ $@ $@ $@ |
+------+-------------+-------------------+
Run Code Online (Sandbox Code Playgroud)
现在我需要将下表中的现有lat/lng对转换并移动到spatial_table.我将如何构建我的查询以实现此目的?我目前正在使用下面的查询来插入.
mysql> insert into spatial_table values (1, GeomFromText('POINT(1 1)'), GeomFromText('POLYGON((1 1, 2 2, 0 2, 1 1))'));
Query OK, 1 row affected (0.00 sec)
mysql> insert into spatial_table values (1, GeomFromText('POINT(10 10)'), GeomFromText('POLYGON((10 10, 20 20, 0 20, 10 10))') );
Query OK, 1 row affected (0.00 sec) …
Run Code Online (Sandbox Code Playgroud) 我有一个博客文章的表.我想选择最新的帖子,并使用PHP回显它们之间的分隔符,类似于下面的示例.我在考虑将所有结果存储在PHP数组中然后回显,是否有更简单的方法通过MySQL?
Thursday, Sept 8th
-----------------------
Post 1
Post 2
Friday, Sept 9th
-----------------------
post 3
post 4
Run Code Online (Sandbox Code Playgroud)