lovefield | relational database for web apps
kandi X-RAY | lovefield Summary
Support
Quality
Security
License
Reuse
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here
lovefield Key Features
lovefield Examples and Code Snippets
Trending Discussions on lovefield
Trending Discussions on lovefield
QUESTION
Google Lovefield is a JS relational database layer on top of IndexedDB: https://github.com/google/lovefield
In their FAQ, it is said to be (or have been) in use by gmail.
It seems to no longer be developed and hardly maintained, and while the docs are not bad, I couldn't find a lot of information / tutorials for it.
I also didn't find information on whether it has been abandoned, or if it is continued or was transformed into another library.
If anyone has concrete information about the state of this library or derived products then I'll be happy to know.
ANSWER
Answered 2021-Mar-13 at 18:18According to comments from GitHub, it is in "long-term maintenance mode".
This means basically abandoned, but good enough for production for now. https://github.com/google/lovefield/issues/266#issuecomment-678883485
https://github.com/google/lovefield/issues/270#issuecomment-708864795
QUESTION
I have a data set and should clean it. One example from my data:
new<-"\\nLocation:\\nMy home is conveniently located around the corner from the Galleria Mall. There's an abundance of food options in every direction of my place. There are also 2 movie theaters within 5 minute driving distance. Addison which is known for their restaurants and nightlife is a 5 minute drive.\\n-DFW ; Lovefield Airport 20min\\n-American Airlines Center 15min\\n-Downtown 15min\\n-Deep Ellum, Lower Greenville, Uptown 20min"
I tried to use this function:
str_replace_all(new, "[\n]", "")
But it does not work.
My questions:
- What difference between \n and \\n
- How to remove it?
ANSWER
Answered 2021-Jan-20 at 07:14'\n'
is a new line character whereas '\\n'
is an escaped backslash followed by 'n'
.
You can remove it by using gsub
:
gsub('\\\\n', '', new)
QUESTION
What are the specific steps to add a SharedWorker
to an @angular/cli >1.2
-generated project. I would like the SharedWorker to be defined in TypeScript (with full/correct type-definitions editor support), to share interfaces with the main project, and to be continuously compiled and tested along with the main project.
I haven't discovered an example or blog post that describes how to modify a cli-generated project to include either a Worker
or a SharedWorker
. However, there are several posts (such as this one) which show how to transform an entire cli-generated project to run it as a web worker. But that's not my use-case.
I want to confine interaction with a Lovefield database to a SharedWorker
that runs in a separate process from the main application.
Though I've experimented a bit attempting to figure this out, I haven't made much progress. Hopefully someone can save me (and future readers) a lot of time.
ANSWER
Answered 2017-Dec-08 at 13:20I got this to work following these steps:
- Create folder
src\app\shared-worker
Create file
src\app\shared-worker\shared-worker.d.ts
with the following contents:SharedWorker definitions
declare module SharedWorker {
interface AbstractWorker extends EventTarget {
onerror: (ev: ErrorEvent) => any;
}
export interface SharedWorker extends AbstractWorker {
port: MessagePort;
onconnect: (messageEvent: MessageEvent) => void;
}
}
declare var SharedWorker: {
prototype: SharedWorker.SharedWorker;
new(stringUrl: string, name?: string): SharedWorker.SharedWorker;
};
// Merely added the onconnect() method to the file provied via:
// npm install --save-dev retyped-sharedworker-tsd-ambient
// Definitions by: Toshiya Nakakura
Create file src\app\shared-worker\shared-worker.ts
with the following demo contents:
Sharedworker source
///
(self).onconnect = (connectEvent: MessageEvent) => {
const messagePort: MessagePort = (connectEvent.ports as MessagePort[])[0];
messagePort.onmessage = function (messageEvent: MessageEvent) {
const workerResult: number = messageEvent.data.firstNumber * messageEvent.data.secondNumber;
messagePort.postMessage(workerResult);
};
};
Update src\app\app.component.ts
as follows:
AppComponent
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
import { Subject } from 'rxjs/Subject';
import { Observable } from 'rxjs/Observable';
@Component({
selector: 'app-root',
template: `
Invoke Shared Worker
Result: {{result$ | async}}`
})
export class AppComponent implements OnInit {
public firstNumber = 4;
public secondNumber = 8;
private resultSubject = new Subject();
private sharedWorker: SharedWorker.SharedWorker;
public result$: Observable;
public ngOnInit(): void {
this.result$ = this.resultSubject.asObservable();
if ('SharedWorker' in window) {
this.sharedWorker = new SharedWorker('app/shared-worker/shared-worker.js');
this.sharedWorker.port.onmessage = (messageEvent: MessageEvent) => {
this.resultSubject.next(messageEvent.data);
this.changeDetectorRef.detectChanges();
};
}
}
public postMessageToSharedWorker() {
if (!('SharedWorker' in window)) {
return;
}
this.sharedWorker.port.postMessage({ firstNumber: this.firstNumber, secondNumber: this.secondNumber });
}
constructor(private changeDetectorRef: ChangeDetectorRef) { }
}
Add "app/shared-worker/shared-worker.js"
to the apps.assets
node in .angular-cli.json
concurrently
as a dev dependency: npm i -D concurrently
Create package.json
scripts
package.json
"wrk-w": "tsc --noLib --experimentalDecorators --watch node_modules/typescript/lib/lib.es6.d.ts src/app/shared-worker/shared-worker.d.ts src/app/shared-worker/shared-worker.ts",
"dev": "concurrently --kill-others \"npm run wrk-w\" \"npm run start\""
QUESTION
CREATE TABLE message
(`id` int, `from_user_id` text, `to_user_id` text, `created` datetime, `message` text)
;
INSERT INTO message
(`id`, `from_user_id`, `to_user_id`, `created`, `message`)
VALUES
(1, 'a', 'b', '2013-01-14 00:00:00', 'hello'),
(2, 'b', 'a', '2013-01-14 00:00:00', 'world'),
(3, 'b', 'a', '2013-01-15 00:00:00', 'hi!!')
;
I want to get the last messages applicable to (either sent / received by ) a user. In the above example, there are only 2 users (a, b), and the last message applicable to them is id = 3. So the expected result is
'a', 3, 'b', 'a', '2013-01-15 00:00:00', 'hi!!'
'b', 3, 'b', 'a', '2013-01-15 00:00:00', 'hi!!'
There are similar questions in SO, the closest I found was here
The last answer seems to what I wanted, but it is complex to wrap my head around, and also couldn't make it work.
I use lovefield and run it in the browser. It supports join and subset of sql syntax, but may not advanced use. Below code gives last message for a provided user id, but I want rows for all users.
SELECT m.*
FROM message m
WHERE 'a' in (from_user_id, to_user_id) AND
m.created = (SELECT MAX(m2.created)
FROM message m2
WHERE (m2.from_user_id = m.from_user_id AND m2.to_user_id = m.to_user_id) OR
(m2.from_user_id = m.to_user_id AND m2.to_user_id = m.from_user_id)
)
ORDER BY m.created DESC
ANSWER
Answered 2019-Nov-15 at 20:56Below code gives last message for a provided user id, but I want rows for all users.
Your query looks fine. Just remove the condition that filters on a specific user, and you should get the result that you expect:
SELECT m.*
FROM message m
WHERE m.created = (SELECT MAX(m2.created)
FROM message m2
WHERE (m2.from_user_id = m.from_user_id AND m2.to_user_id = m.to_user_id) OR
(m2.from_user_id = m.to_user_id AND m2.to_user_id = m.from_user_id)
)
ORDER BY m.created DESC
Here is an updated version of your fiddle. I added a few more records for other users, and the query returns:
id from_user_id to_user_id created message
4 d c 2013-01-17T00:00:00Z yo!!
3 b a 2013-01-15T00:00:00Z hi!!
QUESTION
I am going thru IndexDB
or lovefield
but so far could not find way to search partial text like we do in SQL queries via LIKE
keyword. Can someone guide me how could it be achieved?
ANSWER
Answered 2018-Apr-23 at 11:18lovefield
has the match
function for pattern matching which is similar to the SIMILAR
keyword in SQL which inturn is similar to the LIKE
keyword. Please have a look at it and see if it does the job
https://github.com/google/lovefield/blob/master/docs/spec/04_query.md
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install lovefield
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page